Background
We have a .NET library referencing one of our unmanaged DLLs, say:
So far, Unmanaged.dll has only been 32-bit, so DotNet.dll is marked with a 32-bit CPU type.
Need to add 64-bit support. How to organize a DLL? DotNet.dll IL code will be the same for 32-bit and 64-bit versions.
Option 1
- 32-bit library folder
- DotNet.dll, processor type 32-bit
- Unmanaged.dll compiled as 32-bit
- 64-bit library folder
- DotNet.dll 64-bit processor type
- Unamanged.dll compiled as 64-bit
In this case, the developer using these libraries is forced to make 2 applications: 32-bit and 64-bit. But in this case I know exactly what is happening.
Option 2
This is the same as Option 1, except that DotNet.dll is of the AnyCPU processor type.
- 32-bit library folder
- DotNet.dll, processor type AnyCPU
- Unmanaged.dll compiled as 32-bit
- 64-bit library folder
- DotNet.dll, processor type AnyCPU
- Unamanged.dll compiled as 64-bit
I donβt like this, because the developer using these libraries when redistributing his application cannot do a good job to make his application not crash without setting the processor type in his application:
- If they use the 32Bit Libraries Folder, in a 64-bit OS their process will crash
- If they use the 64Bit Libraries Folder, on a 32-bit OS their process will crash
This makes Option 1 above Option 2.
Option 3
- Unmanaged_x32.dll compiled as 32-bit
- Unmanaged_x64.dll compiled as 64-bit
- DotNet.dll, processor type AnyCPU
DotNet.dll at runtime will determine which bit it launches, and then PInvoke the correct Unmanaged.dll.
Question (s)
- As a developer of these libraries, which option makes sense?
- As a developer using the DotNet.dll library, which option makes the most sense?
- For option 3, if you are using DotNet.dll, would you like to know that the runtime library determines what Unmanaged.dll to use?
- How about redistributing your application with these libraries?
- Are there any missing options?
earlNameless
source share