none
System.DllNotFoundException when two program load same DLL RRS feed

  • Question

  • An exception occurs  in my application,when C# application try load one C++ DLL.  it shows : System.DllNotFoundException: Unable to load DLL (Exception from HRESULT: 0x8007045A) . It's very strange , it's only occurs in such step:

    1. A_user  starts one tomcat server,  in one webservice(A_web) of this server use java code "Runtime.getRuntime().exec(a.exe) " to run A program in A_PATH(all need c++ dll in this path)。Call the A_web service, so A program runs and loads all dll.

    2。B_user starts B program in B_PATH(all need c++ dll in this path).when it try load dll, it will throw DllNotFoundException.

    Both A and B are C# program in one PC. A and B can run without error when start in normal way(form cmd). And exchange steps above, run B first and A second, NO exception occurs.

    It seems that java server adds something on DLL loading. Without such server, all is OK. But what? I use procmon try to find some reason, it shows two difference between two result(right B/wrong B):the wrong one will try twice on get *dll.manifest and *dll.config and failed(the right one try each once and failed);the wrong one don't has ReadFile operation on dll but right one has and succeed.

    Can anyone give some reason about this?

     

    Tuesday, September 7, 2010 5:57 AM

Answers

  • The tomcat server has a reference to the file. Servers operate a bit differently than regular programs. The worker process (process that runs on the server) usually holds on to files until the app domain unloads or executable terminates. Only then is the resource released. On the other hand, regular programs release file resources once the application terminates.
    • Marked as answer by SamAgain Wednesday, September 15, 2010 9:33 AM
    Thursday, September 9, 2010 1:58 AM

All replies

  • The tomcat server has a reference to the file. Servers operate a bit differently than regular programs. The worker process (process that runs on the server) usually holds on to files until the app domain unloads or executable terminates. Only then is the resource released. On the other hand, regular programs release file resources once the application terminates.
    • Marked as answer by SamAgain Wednesday, September 15, 2010 9:33 AM
    Thursday, September 9, 2010 1:58 AM
  • We temporarily mark a reply, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Please mark the right answer at the right time.
    Thanks,
    Sam
    Wednesday, September 15, 2010 9:35 AM