Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / May 2006

Tip: Looking for answers? Try searching our database.

DllImport attribute and platform independence

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cody - 24 Apr 2006 20:30 GMT
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?
Greg Young [MVP] - 26 Apr 2006 02:21 GMT
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
> Is it possible to redistibute a .net app compiled with vs to linux without
> recompiling with say mon compiler?
[quoted text clipped - 11 lines]
> Is it possible to call methods from an external dll without using the
> dllimport attribute, something like GetProcAddress in the old days?
hB - 01 May 2006 05:44 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.