BalaShiyamala / opencvdotnet

Automatically exported from code.google.com/p/opencvdotnet
0 stars 0 forks source link

Cannot compile native/unmanaged code #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

Whenever I create a new MSRS project and include the DLL for
OpenCVDotNet.dll I receive the error:

OpenCVDotNet is not a strong named assembly.

So I found instructions on how to create a strong named assembly.

The solution of assigning the strong name to the third part DLL by using
following command on visual studio command prompt.

Step 1: Dis-assemble the assembly
        ildasm OpenCVDotNet.dll /outSurprisepenCVDotNet.il

Step 2: Re-Assemble using your strong-name key
        ilasm OpenCVDotNet.il /resSurprisepenCVDotNet.res /dll
/keySurprisepenCVDotNet.snk /outSurprisepenCVDotNet.dll

This code work perfectly to assign strong name.

for verification you can use following command,
sn -vf OpenCVDotNet.dll

After step 2 I receive a bunch of these errors repeatedly:

OpenCVDotNet.il(3206) : error -- Cannot compile native/unmanaged method
OpenCVDotNet.il(3213) : error -- Local (embedded native) PInvoke method,
the resulting PE file is unusable

And after step 3, I receive the error:

OpenCVDotNet.dll does not represent a strongly named assembly

I think the strong hint here is the error Cannot compile native/unmanaged
method. But I dont' understand what this means and how to fix it?

Original issue reported on code.google.com by Melanie....@gmail.com on 21 Jun 2008 at 6:02

GoogleCodeExporter commented 8 years ago
Hi Melanie...

I'm just diving into both Open CV and MSRS, but I've been a .NET user for a 
number of
years... and have run into this problem myself...

IIRC, there's some sort of keyword you can add to the function declarations (aka
unmanaged methods) - I think in C# it's "unsafe" but I'm not sure - I think 
you're
right about that error message, the unmanaged calls are what's tossing you...

Also try switching from debug to run mode or back - I've had projects that 
would toss
those kinds of errors in release mode, but not in debug mode, in the past...

FYI, the MSRS RoboChamps Amazed Challenge referee would've thrown this error no
matter what - it was a signed-code system itself... meaning you couldn't call 
any
unmanaged code - it was designed that way so some sneaky individual didn't just 
wire
their joystick up to some P/Invoke calls and cheat...

Hopefully some of this helps!

Original comment by merlin...@gmail.com on 29 Jun 2008 at 12:31