Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have 2 DLLs, 1 is for Windows only (uses some Windows specific DLLs which are not supported by Mono) and 1 is for Mono. The method prototypes of those DLLs are all the same.
If Mono is detected the LJUDMono should be imported, else LJUDWin. And I'd like to do it statically with DLLImport.

Any suggestions? Resources?

To do it dynamically I found this article Fast late-bound invocation through DynamicMethod delegates[^].
Posted

Why don't you just deploy the two versions in different setups, obviously you will know which platform you will be running on so just package your files accordingly.
 
Share this answer
 
Comments
BobJanova 13-Oct-11 9:33am    
Giving this a 5 for being the simplest and best approach in most cases.
Mehdi Gholam 13-Oct-11 9:36am    
We like simple things, programming is complex enough :)
You can't do it statically, almost by definition (the choice you are making is a runtime one). The simple solution is to deploy one DLL, and make it the appropriate one for the platform, as Mehdi suggests. If for some reason you can't do that, the best approach is probably a plugin based one whereby you choose which assembly to load at runtime, and have each assembly have a class which implements ILJUDMethods which you can instantiate. (Search CP for plugin based architectures if you aren't aware of how to make it work; you should just need the simple, one AppDomain version here as you don't need to unload or version-control the plugins.) That way, you only have one slow piece of late binding (essentially, binding the type to the right assembly), and everything after that can go through the interface (which should be declared in an assembly that the application and both plugins have access to do, either the application or a fourth separate DLL, depending on whether these classes are application dependent).
 
Share this answer
 
Comments
Mehdi Gholam 13-Oct-11 9:37am    
My 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900