Emmanuel
Emmanuel

Reputation: 14209

Migrating down from .NET 2.0 to .NET 1.1 - DllImport no longer works

One of our apps is in C#/.NET 1.1/VS2003 and needs to remain as is :-(

I need to use code from another C# assembly that is in .NET 2.0: because of technical restrictions (.NET 1.1 mandatory, so direct use of .NET 2.0 impossible), I took code away from the .NET 2.0 project to try to adapt it to .NET 1.1 (not easy, since no generics, partial forbidden, etc).

My 1.1 code now compiles, but fails at execution time because of an EntryPointNotFoundException due to P/Invoke to an unmanaged DLL.

What's strange is that I tried to validate my changes first in .NET 2.0, and I don't have any problem importing the DLL:

[DllImport(FreeImageLibrary, EntryPoint = "FreeImage_GetFileTypeFromHandle")]
public static extern FREE_IMAGE_FORMAT GetFileTypeFromHandle(ref FreeImageIO io, fi_handle handle, int size);

The declaration is the same in both projects, of course the DLL is the same as well. dumpbin.exe gives for the signature:

_FreeImage_GetFileTypeFromHandle@12

I also tried to declare the entry point with this name, but that does not work either, as well as trying desperately to change CallingConvention, CharSet, ExactSpelling... No way !

This may come either:

Many thanks for your expertise !

Upvotes: 4

Views: 376

Answers (1)

Emmanuel
Emmanuel

Reputation: 14209

Oh - I just became aware that I had a DLL name collision that raised this issue (.NET project and unmanaged DLL with the same name)... Ouch ! Sorry, my question's totally pointless then. Thanks for reading anyway !

Upvotes: 1

Related Questions