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 / Interop / October 2004

Tip: Looking for answers? Try searching our database.

DllImport, how to dinamically assing the DLL path?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luis Fajardo - 20 Oct 2004 20:51 GMT
I don't want to put the .DLL in a known OS path folder, I'll like to define
or load the .DLL from an specific location at runtime.  How should I do it?

Thanks in advance
James - 20 Oct 2004 21:01 GMT
You can always put the dll in the same folder as your
executable or referencing assembly.  I have seen articles
on this around the net but can't find one right now.

>-----Original Message-----
>I don't want to put the .DLL in a known OS path folder, I'll like to define
>or load the .DLL from an specific location at runtime.  How should I do it?
>
>Thanks in advance
>.
Luis Fajardo - 20 Oct 2004 21:09 GMT
James, thanks for your answer.  What if the assembly is on the GAC?  I'm
dealing with versioning issues, that's why I need to know where to locate the
.DLL.  I need to be able to run two versions side by side, that means 2
assemblies on the GAC, and 2 .DLL, each set with different version levels.

Thanks

> You can always put the dll in the same folder as your
> executable or referencing assembly.  I have seen articles
[quoted text clipped - 8 lines]
> >Thanks in advance
> >.
James - 20 Oct 2004 21:27 GMT
To make sure I understand:  You'll have 2 .NET assemblies
and two legacy Dlls.  You want each .NET assembly to
reference a specific version of the legacy Dll.

If this is the case then the trouble is with the way
Windows loads Dlls - there are no provisions for choosing
which version you want your .NET assemblies to load.  My
*guess* is that you may have to avoid using the DllImport
attribute and load them manually.  The Win32 API *might*
give you the flexibility to do this, but this is way out
of my league.

>-----Original Message-----
>James, thanks for your answer.  What if the assembly is on the GAC?  I'm
[quoted text clipped - 18 lines]
>>
>.
William DePalo [MVP VC++] - 20 Oct 2004 21:11 GMT
>I don't want to put the .DLL in a known OS path folder, I'll like to define
> or load the .DLL from an specific location at runtime.  How should I do
> it?

This is just thinking out loud, though, as I have never tried it but ...

On very recent platforms (2K+3, XP/SP1) SetDllDirectory() might come in
handy. I'm not sure if it has a .Net equivalent or if you'd need to use
P/Invoke.

Regards,
Will
Robert Jordan - 21 Oct 2004 00:24 GMT
Hi Luis,

> I don't want to put the .DLL in a known OS path folder, I'll like to define
> or load the .DLL from an specific location at runtime.  How should I do it?

http://www.codeproject.com/csharp/dyninvok.asp

bye
Rob

Rate this thread:







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.