Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load MFC DLL from C# web service...

0 views
Skip to first unread message

gr...@ram-software.com

unread,
Oct 11, 2007, 10:50:18 AM10/11/07
to
Hello,

I'm having problems loading my MFC exported function from my C# Web
service. I'm using the DllImport to load the dll and declare the
function like the following:

[DllImport("MyDLL.dll")]
public extern static int MyFunction();

and in the MFC dll it is exported like the following:
__declspec(dllexport) int MyFunction();

When I try to run the web service that makes the call to MyFunction I
get a "Unable to Load DLL" error - what all am I missing? Is their
anything special I need to be doing for loading an MFC Dll from a C#
Web Service?

Thanks,
Greg
gr...@ram-software.com

Nicholas Paldino [.NET/C# MVP]

unread,
Oct 11, 2007, 11:00:55 AM10/11/07
to
Greg,

When your ASP.NET page is compiled, it is placed in a temporary space,
and that directory the assembly is in is used as the search path for the
call to LoadLibrary (which the P/Invoke layer is using to load the unmanaged
DLL).

In order to get around this, you have to place MyDLL.dll in a directory
that LoadLibrary can find it in (see the documentation for details) which is
not based on the relative path of your compiled assembly, or you have to
place the full path name of the dll in the DllImport attribute.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

<gr...@ram-software.com> wrote in message
news:1192114218.0...@o3g2000hsb.googlegroups.com...

0 new messages