HighTechTalks DotNet Forums  

DllImport attribute and platform independence

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss DllImport attribute and platform independence in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
cody
 
Posts: n/a

Default DllImport attribute and platform independence - 04-24-2006 , 03:30 PM






Is it possible to redistibute a .net app compiled with vs to linux without
recompiling with say mon compiler?

And what if I import functions from external non-.net dlls like

[dllimport("fmod.dll")]
public static extern fmod_playsound(string file, int flags);

the library fmod itself is platform independent but there are certainly
different versions of the library for each plaform having different file
name and different internal image format, so how can such an issue be
solved?

Is it possible to call methods from an external dll without using the
dllimport attribute, something like GetProcAddress in the old days?



Reply With Quote
  #2  
Old   
Greg Young [MVP]
 
Posts: n/a

Default Re: DllImport attribute and platform independence - 04-25-2006 , 09:21 PM






Yes it is possible to do copy ony deployments to a mono system providing all
of the bits you are using exist there.

dllimports to external code do however break this (obviously if the library
does not exist on the other platform). For this you generally end up with
coditional code "if windows, if mono etc". If you are using a platform
independent library you can also use DLLMap to handle this for you
http://www.mono-project.com/DllMap

Cheers,

Greg
"cody" <deutronium (AT) gmx (DOT) de> wrote

Quote:
Is it possible to redistibute a .net app compiled with vs to linux without
recompiling with say mon compiler?

And what if I import functions from external non-.net dlls like

[dllimport("fmod.dll")]
public static extern fmod_playsound(string file, int flags);

the library fmod itself is platform independent but there are certainly
different versions of the library for each plaform having different file
name and different internal image format, so how can such an issue be
solved?

Is it possible to call methods from an external dll without using the
dllimport attribute, something like GetProcAddress in the old days?





Reply With Quote
  #3  
Old   
hB
 
Posts: n/a

Default Re: DllImport attribute and platform independence - 05-01-2006 , 12:44 AM



Instead of using DLLImport attribute, Load the libraries at runtime by
the platform provided APIs to load the dynamic link libraries. So you
have all library information provided at runtime like path and name...
And wrap those apis in your class that can behave based on two or more
operating system platforms. (Also you can use different
api-loader-class which one is specific to the platform and they all
implement same interface. you can load specific class through
reflection as well).
I have no experience with DLLMap, but it might be a good idea to go on
with it..

---
hB


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.