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 / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Load DLLs compiled using Mingw

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brandon McCombs - 31 May 2007 04:34 GMT
Hello,

Yesterday I just started using Visual C# 2005 Express Edition and I'm
trying to load external DLLs. I started out with trying to load just one
like so:

[DllImport("libtest.dll")]
        static extern void connections_init();

However when I call the function that wraps connections_init() I'm told
it can't find the libtest.dll and therefore an exception is generated.
This dll is compiled using the Mingw tools.  Could that be the problem?
 I know that the library can be loaded if using VS6 or VS2003.  Also,
my syntax is correct since I can use user32.dll and pop up a message box
with text. I also noticed that if I run regsvr32 on libtest.dll it says
it can't find the library either and of course that is outside of the
VC# 2005 environment. I also placed libtest.dll in c:\windows\system32
and it didn't help.  Any ideas?

thanks
Walter Wang [MSFT] - 31 May 2007 10:40 GMT
Hi Brandon,

Is it possible that this libtest.dll depends on other dlls that are not in
the same directory with it or in PATH environment? You can use Dependency
Walker (http://www.dependencywalker.com/) to view the dependent files.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Brandon McCombs - 31 May 2007 13:44 GMT
> Hi Brandon,
>
> Is it possible that this libtest.dll depends on other dlls that are not in
> the same directory with it or in PATH environment? You can use Dependency
> Walker (http://www.dependencywalker.com/) to view the dependent files.

Well I know it uses other DLLs but not sure if they are strictly
required. Do I need to specify a DllImport attribute for any DLLs
libtest.dll may depend on or will libtest.dll be able to access them
without importing them?

> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
[quoted text clipped - 6 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 01 Jun 2007 04:55 GMT
Hi Brandon,

You don't need to import every dependent dlls that libtest.dll uses.
However, if they're not in the same directory of libtest.dll, they need to
be put in a directory that in the PATH environment. Please note if one of
your dependent dll also depends on other files, this rule also applies.
That's why most of the shared dlls are put under %windir%\system32 because
normally this dll is always in the PATH environment.

Let me know if there's anything unclear. Thanks.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Brandon McCombs - 01 Jun 2007 23:43 GMT
> Hi Brandon,
>
[quoted text clipped - 17 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Arne Vajhøj - 10 Jun 2007 00:26 GMT
> Yesterday I just started using Visual C# 2005 Express Edition and I'm
> trying to load external DLLs. I started out with trying to load just one
[quoted text clipped - 6 lines]
> it can't find the libtest.dll and therefore an exception is generated.
> This dll is compiled using the Mingw tools.  Could that be the problem?

How do you link it ?

Have you tried specifying full path to the DLL in the DllImport ?

>  I know that the library can be loaded if using VS6 or VS2003.  Also, my
> syntax is correct since I can use user32.dll and pop up a message box
> with text. I also noticed that if I run regsvr32 on libtest.dll it says
> it can't find the library either and of course that is outside of the
> VC# 2005 environment.

regsvr32 are for COM DLL's not for Win32 DLL's.

Arne
Ben Voigt [C++ MVP] - 10 Jun 2007 01:38 GMT
>> Yesterday I just started using Visual C# 2005 Express Edition and I'm
>> trying to load external DLLs. I started out with trying to load just one
[quoted text clipped - 6 lines]
>> it can't find the libtest.dll and therefore an exception is generated.
>> This dll is compiled using the Mingw tools.  Could that be the problem?

Is libtest.dll in the same directory as your .exe?

Did you open it with Dependency Walker (www.dependencywalker.com) and see if
"connections_init" function is exported?

If you know are using mingw tools, are you a C++ programmer?  C++/CLI lets
code use both native and managed libraries seamlessly, and create a .NET
library that C# can use just like the built-in classes.

> How do you link it ?
>
[quoted text clipped - 9 lines]
>
> Arne

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.