Reputation: 6102
I have a .dll that I generated thorugh a C++ project. I have to use this dll in my ASP.NET project and I have written DllImport functions for the same in my project.
The static class inside App_Code
has some DllImport
functions
public static class Functions
{
[DllImport("MyFav.dll", EntryPoint = "fnmain",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern StringBuilder fnmain();
}
Since I could not add the C++ dll directly as a reference in my ASP.NET project (because it is not a .NET assembly), I just copied into the top level directory. ( Name of ASP.NET Project-> Right Click -> Add Existing Item )
Now, when I try to run the project, I get the following error:
Exception:
Unable to load DLL 'MyFav.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Any suggestions? Where has the .dll to be kept?
Upvotes: 2
Views: 3081
Reputation: 77606
I had a similar error, but using Mono's XSP server. For this server, the solution is to put the dll in the root of your web app (the parent folder of ./bin
). That happens to also be the current working directory (when run from Xamarin Studio), which is presumaby related.
Upvotes: 1
Reputation: 11787
if to be used with out path copy paste the dll
to bin directory in your project folder
.
Upvotes: 0
Reputation: 19465
The .dll
should be in the \bin
folder of your asp.net application.
Apparently there are rules for how dlls are resolved. See Dynamic-Link Library Search Order on msdn
You could also try:
[DllImport("C:\path_to_dll\MyFav.dll", EntryPoint = "fnmain",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern StringBuilder fnmain();
If all this doesn't work, maybe your MyFav.dll
has additional unresolved dependencies. You could use Dependency Walker to check for these.
Upvotes: 1