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

One of our applications is located in C # /. NET 1.1 / VS2003 and should remain as follows: - (

I need to use the code from another C # assembly that is in .NET 2.0: due to technical limitations (.NET 1.1 is required, so using .NET 2.0 directly is not possible), I deleted the code from the .NET 2.0 project to try to adapt it to .NET 1.1 (not easy, since there are no generics, partially forbidden, etc.).

My 1.1 code is now compiling, but not executing at runtime due to EntryPointNotFoundException due to P / Invoke in an unmanaged DLL.

What is strange is that I first tried to check my changes in .NET 2.0, and I have no problem importing the DLL:

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

In both projects, the declaration is the same, of course, the DLL, too. dumpbin.exe gives for signature:

 _FreeImage_GetFileTypeFromHandle@12 

I also tried to declare an entry point with this name, but this also does not work, and also desperately trying to change CallingConvention , CharSet , ExactSpelling ... No !!

This can happen either:

  • due to a change in the way DllImport works between .NET 1.1 and 2.0, but I did not find anything that happens this way

  • due to the error of my porting code from .NET 2.0 to 1.1, but I don’t see how it could be exact in this case (I even tracked the code to see the sizes of the arguments, io and handle , in both cases they are the same)

  • ... that I cannot think of!

Thanks so much for your experience!

+4
source share
1 answer

Oh, I just found out that I came across the name of the DLL that raised this problem (.NET project and unmanaged DLL with the same name) ... Oh! Sorry, my question is completely meaningless. Thanks for reading anyway!

+1
source

Source: https://habr.com/ru/post/1340155/


All Articles