If broken it is, fix it you should

Using the powers of the debugger to solve the problems of the world - and a bag of chips    by Tess Ferrandez, ASP.NET Escalation Engineer (Microsoft)

Unable to load DLL ‘dllname.dll’: A dynamic link library (DLL) initialization routine failed. 0x8007045A

Unable to load DLL ‘dllname.dll’: A dynamic link library (DLL) initialization routine failed. 0x8007045A

Rate This
  • Comments 13

I recently got an email with the following question:

“Can you give me some very helpful hints with this one ? I am struggling with the following error in an asp.net application.

Exception Message: Internal Error : Unable to load DLL 'RdbNet.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) The RdbNet.dll is an .NET dll from Oracle so I can't debug into it.

If I use a windows forms application I never have the error. I have already used procmon, filemon and regmon to search for access denied, not found... and so but couldn't find a reasonable one.”

My note: The actual .net Exception is System.DllNotFoundException

I don’t really have a silver-bullet answer for this one, but I thought I’d discuss how I would go about troubleshooting this if it happened to me or if I got a case on it.

Potential causes

An “initialization routine failed.” problem generally occurs because a) some dll that this dll referenced was not found or b) something in the init method failed.

The problem is that option B could really mean anything, such as the init routine making calls that require permissions that you don’t have, or for example that it interacts with the desktop which is not permitted from a service etc.

The most common issue though is that the component was not properly installed, so that some of its dependencies are not available.

Differences between web forms and win forms (in this context)

The most apparent difference between a web forms and a win forms application is the user context that it runs under.  Unless you’re impersonating or the app pool id is changed, the application pool runs under the network service account which has very limited access. 

Another big difference is that an asp.net service is not allowed to interact with the desktop. 

There are of course a lot of other differences but these are the two that I think may be relevant for this issue.

Where to go next

1. Run filemon + regmon to look for not found or access denied

My first troubleshooting step is exactly what they mention that was done in the email.  Running procmon (filemon+regmon) to look for not found or access denied, specifically focusing on the files that RdpNet.dll depends on.  A quick search gave me this link to the release notes of the Oracle RDB Provider for .NET including the dependencies for it.

I still believe that there might be something in there, but it is a bit tricky to look at these files if you are not exactly sure what you are expecting to find.   A neat trick, since there is a working win forms solution is to run filemon+regmon when it works to see if it accesses some files that it didn’t access in the web forms case.

The other thing that is interesting here is to find out if it was tested in a win forms application on the same machine as the web server.  This would tell us if we can exclude the idea of some dependencies missing.

2. Reinstall the component

If the win forms app was not tested on the actual web server I would simply reinstall the component as this is a quick and easy step to make sure things got registered properly.

3. Test with elevated permissions

If the problem reproduces on a development server or a test server you can temporarily create a new application pool running under a user that has high permissions (admin or similar) to see if the problem still reproduces.  If it does, then you have a permissions issue and it is back to filemon/regmon again.   I wouldn’t recommend running with elevated permissions live of course, but in a test/dev environment it would be an ok step to try.

4. Get a memory dump on the Exception and log stack traces for all first chance exceptions

With debug diag you can set up a crash rule for the w3wp.exe process and configure it to “Log Stack Trace” for unconfigured first chance exceptions, and then use “add exception” to add a specific action for the CLR (.NET) Exception System.DllNotFoundException and ask it to create a full dump when this exception occurs.

For more info on setting up such rules see http://blogs.msdn.com/tess/archive/2009/03/20/debugging-a-net-crash-with-rules-in-debug-diag.aspx

Once you have the log and the dump, look in the log for exceptions (native or .net) that occurred just before the System.DllNotFoundException as this is probably what later bubbled up to generate this exception.

In the dump you can dump out all recent .net exceptions to see if some exception has occurred recently that might lead up to the exception you are seeing now.  

5. Contact the vendor of the component

If you can’t get anything from the above steps I would suggest contacting the vendor of the component.  Sometimes (I don’t believe it is the case with this particular component though) the dll you are trying to use is not mean to be used from ASP.NET because it interacts with the desktop, uses System.Drawing or similar.  

Perhaps you need to configure something to be able to use it from ASP.NET or they can tell you what permissions are needed etc.

If you ran through step 4 and did get a call stack for an exception occurring in one of their components right before the DllNotFoundException occurred, that is usually very useful.

 

Laters,
Tess

  • My guess is that this is a permissions issue. By default, the Oracle Client (or at least the 9.x client) installed some of its DLLs with permissions set so the asp.net runtime couldn't access them. (This bit me several years ago. I don't use Oracle that often, so I've forgotten the details.)

  • I recently got an email with the following question: “Can you give me some very helpful hints with this

  • yup, those would be the steps to fix this problem, been there done that

    now, specifically talking about oracrap, an additional issue might be the search path, oracrap installs their dlls under a c:\oracle path where the asp.net app might not be looking for

  • In addition to regmon + filemon, Depends.exe(Dependency walker) is a great tool to check the existence of files on that DLL depends.

  • If RdbNet.dll really is a .NET DLL, then Dependency Walker (which is a fantastic tool for handling COM and regular DLL Hell issues) won't help. But use ILDASM to see the manifest, which should indicate dependent DLLs. Reflector should also show those dependencies.

    Finally, shouldn't the Fusion Log Viewer show you whether any dependent DLLs are failing to be loaded?

    At least you could rule out dependencies as the problem.

    ->A

  • I receive the error "Parser Error Message: Could not load type 'DllName '(Dll That in bin)." when browsing an asp.net page

    I See This Error in Page When I Publish In Server (2003)

    Id  Deploy it in Win2003 but I dont know Why this Happen

    I Search in Internet And Can not find Good Answer For This Error

    ,I Will Change Os Of Server And See This error After 2 month

    Whyyy? Id Dont

    My App is In .net 3.5

  • Alan,

    In fact for RdbNet.dll specifically there is no need to do that since the dependencies are listed in the release notes for it but in general yes, reflector should show you.

    Good idea about fusion log viewer btw.

  • Tess,

    Your blog has really introduced me to the wonderful world of production debugging and helped me to solve many, many issues. It has been sort of inspirational for me in wanting to get out and spread the message in the community about this topic that I feel too few developers know about.

    That being said I was wondering if it would be ok for me to use the app from your debugging labs as part of a talk on production debugging? If you'd like more details to consider before saying yes please email me at swalker AT tdci DOT COM.

  • Forgot to mention in my last comment that I would of course give 100% credit to you for all your work on this and point everyone to your blog. (which I already do anyway!)

  • Scott,  Sure thing, feel free to use it:)

  • Here's an interesting twist on the problem.  We have been using VS 8 for a project that has some requirements for that older tool version.  On 7/29, an automatic update took place.  Subsequent builds of the project worked on the building computer and on other computers with the tools installed.  It would not work on any computer without the VS tools.

    We went to the Microsoft web site, downloaded and installed the .NET framework updates and the redistributable runtime on the failing computers.  No luck.  It was only after another day's work that we found out about the 7/29 update to our build computer.  We took the vcredist_x86.exe file from the build computer, executed it on a failing computer, and then things worked.

    Tentative conclusion: the vcredist_x86.exe on the Microsoft website was not updated at the time of the auto update to the VS tools.  The usual strategy of getting updates for the target systems from Microsoft didn't work in this case.

  • after reinstall Retrospect i get this message

    cannot start and may need reinstallation

    unable to load PCVOL.DLL error

    bad program extention

    the file exists, is lower case is and is not locked.

    why the erorr? please help if possible

  • I went through all or even most of all the sites containing the " Unable to load DLL ‘dllname.dll’: A dynamic link library (DLL) initialization routine failed "  files.  And ended up with Regfix of SmartPCFixer or repsetupmarm  programs to load !  Then when loaded and it runs, it tells me about 100 + faults plus i need to buy the product in Dollars.  They do not tell you it is to buy or for sale, or costs $ X Dollars to register the program.  Is there no other way to just recover the file lost when another program was deleted from my PC ?  Please help, i can not buy another product just to end up buying again  another PC Fixing program ? Thank you all PC lovers.

Page 1 of 1 (13 items)
Leave a Comment
  • Please add 7 and 7 and type the answer here:
  • Post