I'm trying to import a simple messagebox from C# to Perl. To do so I wrapped my C# dll through a C++ code. C# code:
C++ wrapper:namespace ManagerCSharp { public static class ManagedClassTest { public static void ShowValue(ref int value) { DialogResult result = MessageBox.Show("C# Message Box", "C +# Message Box", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) value = 1; else value = 2; return; } } }
public ref class CSharpClass { public: void ShowCSharpMessageBox(int *value) { ManagerCSharp::ManagedClassTest::ShowValue(*value); return; } } __declspec(dllexport) void __stdcall ShowMessageBox2(int *value) { CSharpClass myCSharp; myCSharp.ShowCSharpMessageBox(value); }
With this code I was able to call the dll from a C code. But when I try to call from Perl I get this error:
System.IO.FileNotFoundException: Could not load file or assembly 'ManagerCSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The specified module could not be found.
in CSharpClass..ctor()
in ShowMessageBox2(Int32* value)
My Perl code is:I have all the relevant files on the same folder.use strict; use Win32::API; Win32::API->Import('ManagedCPP.dll', 'void __stdcall ShowMessageBox2(i +nt *value);'); my $result; ShowMessageBox2(\$result);
In reply to Import a DLL from C# to Perl by paulorfmmb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |