Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am developing a Webservice for consuming a Managed C++ dll (C++/CLI dll).
This managed C++ dll is in turn utilizing unmanged (native) C++ dlls [via LoadLibrary ....]

I have added this manged dll to my webservice as reference (and also all it's refered assemblies). Now when I try to use this webservice in ASP or C# client I am getting :

******* Error log start *********

"The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

...................

******* Error log end *********

But the same manged dll I could able to refer (from the same location as I refered from webservice) in an C# console application, which proves that all the required dependencies are available.

Can any one please give me hints/directions to solve this issue.

Any thing peculiar in invoking manged dlls (utilizing unmanaged dlls) in webservice ?
Posted

The error means what it says. A file is missing. Therefore you have not copied it to the server, or the file is there, but not visible to the ASP.NET user. I would suspect the latter, that it's a permissions problem with the ASP.NET user that the web service runs under.
 
Share this answer
 
Comments
Lakamraju Raghuram 31-Jan-12 23:28pm    
As I mentioned already that the same process (referring the required dlls) works fine for normal C# console application.
So like you mentioned the second case (invisible to ASP client) may have something to do with. I want to ask you further:
1. How to make it visible - any clue please.
2. Then what about c# client where I still can't use this webservice - is this visiblity the same reason?
Christian Graus 31-Jan-12 23:31pm    
You don't know how to set file permissions in windows ? Right click on the file, choose properties, and find the security tab. On there, you can see a list of users that have rights. Just add 'Everyone' and give them full access and then try it.
Lakamraju Raghuram 31-Jan-12 23:49pm    
Ha! I taught you are speaking about permission concerned to .NET or some project setting.

I have given full access like you mentioned. BUT STILL NO LUCK. I am getting the same error !!!!
Christian Graus 1-Feb-12 0:02am    
Well, the error means what it says. you are either missing a file, or you've got files and their permissions are not set properly
Lakamraju Raghuram 1-Feb-12 0:11am    
Hmmm .... or is there any way to find 'the missing file' - as the stack trace and error info are not giving much information.

The files are there - if not the normal c# console should crib. And regarding permission I have done what you said.

(:
As I already stated that my managed dll (which the webservice is wrapping) is using a native dll and this is causing the problem.

After identifying the exact (native) dll, I tried to delay load it (just to see if any thing to do with loading) and it worked.

Then I tried to keep this dll in system32 folder and removed delay loading, then also it worked - so I taught that the dll is fine, but webservice is not able to locate it [while it can able to do with other MANAGED dlls]. So only it is giving 'System.IO.FileNotFoundException', even though I placed it in proper path.

Finally I added the path of my native dlls under 'Path' environmental variable [and reverted all the previous tried steps] and it worked.

I am currently holding to this work-around and welcome any suggestions / pro and cons of this approach

[EDIT]
Also do not forget to try with RELEASE build only, as DEBUG build may fail.
 
Share this answer
 
v2
Comments
Lakamraju Raghuram 9-Feb-12 1:36am    
I once again appreciate Christian Graus for his try

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900