Fail to load DLL in Windows 2008 R2 having full permissions control

I have developed an C# application that run very well in local.

But there is a problem when i put on the server.

The application uses a DLL library in his references (A.dll) and in a point of the execution the A.dll creates in the Temp directory another DLL (embedded in it, let's call it B.dll). But when the A.dll try to load the B.dll an exception is threw:

system.invalidoperationexception: failed to load B.dll

I have not access at the DLLs source, are libraries.

So recap:

  • The process have the full control permission on the file and path. (cheked)
  • Is running like Administrator. (checked)
  • In my application if I try to open the dll in binary mode, the operations have no problems.
  • Runs well on every OS that i have tested (Windows 8_64 / XP_32 / 2008_32 / 7_64), but fails with 2008 R2 64.
  • I have tried to ReDownload, rename, reinstall the B.DLL, i have putted the program in the same path of the B.DLL, etc etc, with no results.
  • So at this point I think that is a security problem on the server, like "Processes cannot load DLLs" or something similar.

    The exception: http://i.imgur.com/NmB2Fth.png?1

    Anyone can suggest me any solution? Would i check better? Where?

    PS IF i try to register the dll i got the same error of this: Register DLL file on Windows Server 2008 R2


    The solution was simple.

    I have used a very useful tool named Event Viewer (Start->Execute->eventvwr.exe) When i started my application a new error event was showed on the Windows Logs->Applications:

    Activation context generation failed for "C:TempAPPmyfile.dll". 
    Dependent Assembly Microsoft.VC90.CRT,processorArchitecture="x86",
    publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" could not be found.
    Please use sxstrace.exe for detailed diagnosis.
    

    A quick search and the result was that the server needed the Visual C++ Runtime for x86 (x86 because my application works in the 32bit application pool)

    Once installed this package: http://www.microsoft.com/en-us/download/details.aspx?id=5582

    Everything worked like a charm.

    I hope this will help anyone to save some time!!

    链接地址: http://www.djcxy.com/p/44460.html

    上一篇: LINQPad:尝试使用使用[DllImport]访问C ++ dll的程序集

    下一篇: 未能在具有完全权限控制的Windows 2008 R2中加载DLL