Hi Monks,

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:

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; } } }
C++ wrapper:
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:
use strict; use Win32::API; Win32::API->Import('ManagedCPP.dll', 'void __stdcall ShowMessageBox2(i +nt *value);'); my $result; ShowMessageBox2(\$result);
I have all the relevant files on the same folder.

In reply to Import a DLL from C# to Perl by paulorfmmb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.