I am migrating an classic asp site from Windows 2003 IIS 6 .net framework 1.1 to Windows 2008 32 bit IIS7 .net framework 2.0. I'm facing some strange issue in assembly loading.
There are set of Com callable wrapper dlls written in C# 1.1 and these dlls use a dll registered in GAC (IConfigSectionHandler implementation).
Com callable wrapper fails to load this gac dll and fusion logs says;
*** Assembly Binder Log Entry (3/30/2015 # 6:22:28 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NT AUTHORITY\IUSR
LOG: DisplayName = Enterprise.Configuration
(Partial)
LOG: Appbase = file:///c:/windows/system32/inetsrv/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = w3wp.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Enterprise.Configuration.DLL.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Enterprise.Configuration/Enterprise.Configuration.DLL.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Enterprise.Configuration.EXE.
LOG: Attempting download of new URL file:///c:/windows/system32/inetsrv/Enterprise.Configuration/Enterprise.Configuration.EXE.
LOG: All probing URLs attempted and failed.
If I put this dll to c:/windows/system32/inetsrv it loads in the second attempt.(If I refresh the sites on first failure)
And the Com callable wrappers also load in the second attempt and it also searches the Com callable wrappers in same manner and fails to load at first time.
Why CLR searches Com callable wrappers in c:/windows/system32/inetsrv and why GAC registered dll also searches in the same place.
Any idea
Related
I have a DLL written in C# that runs a job from within the context of a 3rd party application. The DLL needs to reference another 3rd party DLL. Intellisense in VS works great but during runtime the error is generated: "Could not load file or assembly or one of its dependencies. The system cannot find the file specified."
I ran the dependency tool and saw a missing reference to mscorwks and perfcounter.dll. Putting these 2 missing DLLS in the same folder as the 3rd party DLL corrects the missing references in the dependency tool.
I'm not sure what to do next. Where do all these files need to reside for my DLL to work properly? The interesting thing is I also have a stand-alone executable that references the same 3rd party DLL and it doesn't have any issues with missing references.
What should I try next?
Edit:
Downloaded Fusion++ and this is the result from the log. Looks like it can't find the parent. Not sure how to point the dependent DLL to the right folder when it's running in the context of a 3rd party application.
*** Assembly Binder Log Entry (11/24/2019 # 6:59:35 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Autodesk\Vault Professional 2020\Explorer\Connectivity.JobProcessor.Delegate.Host.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = LicenseSpring, Version=4.7.0.0, Culture=neutral, PublicKeyToken=2d5c13cc31edbaaf
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Autodesk/Vault Professional 2020/Explorer/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = Connectivity.JobProcessor.Delegate.Host.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: LicenseSpring, Version=4.7.0.0, Culture=neutral, PublicKeyToken=2d5c13cc31edbaaf
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Vault Professional 2020/Explorer/LicenseSpring.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Vault Professional 2020/Explorer/LicenseSpring/LicenseSpring.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Vault Professional 2020/Explorer/LicenseSpring.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Autodesk/Vault Professional 2020/Explorer/LicenseSpring/LicenseSpring.EXE.
LOG: All probing URLs attempted and failed.
When you added LicenseSpring.dll from disk(via Browse) - VS just copied this DLL and placed it to the package folder. But VS doesn't know anything about dependent DLL. Let's consider that LicenseSpring.dll contains two methods. The first method, do some simple stuff and don't have any dependencies from another DLL. The second method depends on some other DLL. If you call the first method - it will work fine. But when you try to exec the second method - you will get an error:
"Could not load file or assembly or one of its dependencies ...
How to fix this:
When you are adding a library from disk - you need to add all dependencies as well.
You can add your assemblies to GAC - but this will be more complicated
If you cannot find out, what Assembly the system is missing at runtime, you can enable FUSLOG (https://learn.microsoft.com/en-us/dotnet/framework/tools/fuslogvw-exe-assembly-binding-log-viewer) and use Assembly Binding Log Viewer to find out what is missing.
To be honest: FUSLOG is not very comfortable, but it's working great. Don't forget to disable it, when you are done.
I am working on legacy web application and I am getting run time assembly binding error (FileNotFoundException)
I looked into application base directory and can confirm that required DLL with correct version and public token is available under bin/ directory.
I enabled Fusion Log on server to capture details and realized that CLR is probing for assembly in GAC first (I think this is by design for signed assemblies) Below is log for quick reference :
I am able to make it work by installing assembly in GAC - but question and curiosity still remains open why CLR did not picked it from application base directory after it is not found in GAC ?
Also from below log it appears that after GAC, search is performed under directory C:Windows/System32 vs my application directory. I think it's because also logs says it's Running under executable C:\Windows\system32\dllhost.exe
Any help/comment appreciated !!
*** Assembly Binder Log Entry (6/28/2018 # 4:18:02 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (6/28/2018 # 4:18:02 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.DLL.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: Attempting download of new URL file:///C:/Windows/system32/Microsoft.IdentityModel.Clients.ActiveDirectory/Microsoft.IdentityModel.Clients.ActiveDirectory.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (6/28/2018 # 4:18:03 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
*** Assembly Binder Log Entry (6/28/2018 # 4:18:03 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\system32\dllhost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.19.3.10102, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Windows/system32/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = dllhost.exe
Calling assembly : MS.UST.EC.Oem.ServiceProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0753af11def5a5f8.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
The EXE image C:\Windows\system32\dllhost.exe is known as the "COM Surrogate" host. When you want to activate a COM+ component service, and not load it in your own process (for security or stability), dllhost.exe will be invoked to load the component and expose it as an "out of process" activation, then communicate back to your process via some transparent proxy channel, allowing the calling program to pretend that the component is loaded locally.
What this means is that you likely have some code which is being accessed via a COM+ interface and getting launched out-of-process. This code in turn is trying to load the Microsoft.IdentityModel.Clients.ActiveDirectory assembly. The problem is, it's not in your process anymore, and won't participate in any binding policy you've setup (private bin path, binding redirects, etc). This is why you see it trying the GAC first and then failing to find your dll - it's not your process.
Look for any component you might be loading which is a COM component: are you using some COM TypeLib, or a Runtime Callable Wrapper to some COM dll, or do you have any code which inherits System.EnterpriseServices.ServicedComponent?
If you can find where the out-of-process COM component is being launched, you may be able to refactor it to bring the logic in-process and fix your loading issues this way. Otherwise you'll have to put the assemblies in the GAC.
I have a C# program that links to a (large) third-party library and builds successfully with it. All necessary references between my program and the library are included, and the program starts correctly.
Upon loading the .NET managed DLL for the aforementioned library, I get a System.IO.FileNotFoundException that says that the library or one of its dependencies could not be loaded ("The specified module could not be found.").
Since the relevant DLL is present in the Release directory, I went through the fusion event logs and found only binding failures for a bunch of nonexistent <PROJECT>.resource.<DLL|EXE> files under a nonexistent Release\en directory. This doesn't make much sense to me at all, since the project's only resource (a single icon) is internalized.
The logs look like this, with some information redacted:
*** Assembly Binder Log Entry (7/11/2016 # 10:08:49 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Users\USER\Desktop\PROJECT\bin\x86\Release\PROJECT.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = PROJECT.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = PROJECT.vshost.exe
Calling assembly : PROJECT, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\USER\Desktop\PROJECT\bin\x86\Release\PROJECT.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources.DLL.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources/PROJECT.resources.DLL.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources.EXE.
LOG: Attempting download of new URL file:///C:/Users/USER/Desktop/PROJECT/bin/x86/Release/en/PROJECT.resources/PROJECT.resources.EXE.
LOG: All probing URLs attempted and failed.
Update: This is what Process Monitor shows when loading the DLL:
The first three loads are the relevant DLL, and the following ones are (ostensibly) its dependencies, all from the standard VS C++ redistributable.
Update 2: Dependency Walker shows the same DLLs as missing, although this doesn't seem to manifest at load time:
I have a .Net 4.5 project which has been built to a 64-bit DLL that needs to be included in my Web API project. The Web API project is also built to 64-bit. No matter what I try, I keep getting the exception "Could not load file or assembly '*.DLL' or one of its dependencies. The specified module could not be found.". This DLL is created from a mixed-mode project which contains an unmanaged C++ project and a C++/CLI wrapper compiled with /clr.
I have used DependencyWalker to check and make sure all the dependencies DLL are in the same folder as the Web API project as well as the bin folder. I also checked bitness to make sure they are all 64-bit. I then created a C# console project which loads this DLL along with its dependencies and everything worked just fine.
My Web API project uses local IIS 6.2 server and the application pool is using the default identity (ApplicationPoolIdentity). Even if I changed the identity to NetworkService it still failed. At this point I'm out of ideas on how to debug further. I have used Process Monitor before to nail down the missing DLL but not sure how to use it with Web API. Any suggestions on how to proceed with this issue would be appreciated.
Edit - here's the Fusion log:
The operation was successful. Bind result: hr = 0x0. The operation
completed successfully.
Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under
executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information === LOG: DisplayName = TestBridge (Partial) WRN: Partial binding information was supplied for an
assembly: WRN: Assembly Name: TestBridge | Domain ID: 12 WRN: A
partial bind occurs when only part of the assembly display name is
provided. WRN: This might result in the binder loading an incorrect
assembly. WRN: It is recommended to provide a fully specified textual
identity for the assembly, WRN: that consists of the simple name,
version, culture, and public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///D:/build/MSVC/ImageSearchService/ LOG: Initial PrivatePath =
D:\build\MSVC\ImageSearchService\bin LOG: Dynamic Base =
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\imagesearchservice\d0503829 LOG: Cache Base =
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\imagesearchservice\d0503829 LOG: AppName = 7ee35914 Calling
assembly : (Unknown).
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
D:\build\MSVC\ImageSearchService\web.config LOG: Using host
configuration file:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG:
Using machine configuration file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Attempting
download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/imagesearchservice/d0503829/7ee35914/TestBridge.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/imagesearchservice/d0503829/7ee35914/TestBridge/TestBridge.DLL.
LOG: Attempting download of new URL
file:///D:/build/MSVC/ImageSearchService/bin/TestBridge.DLL. LOG:
Assembly download was successful. Attempting setup of file:
D:\build\MSVC\ImageSearchService\bin\TestBridge.dll LOG: Entering
download cache setup phase. LOG: Assembly Name is: TestBridge,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null LOG: A
partially-specified assembly bind succeeded from the application
directory. Need to re-apply policy. LOG: Using application
configuration file: D:\build\MSVC\ImageSearchService\web.config LOG:
Using host configuration file:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config LOG:
Using machine configuration file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Binding
succeeds. Returns assembly from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\imagesearchservice\d0503829\7ee35914\assembly\dl3\584c8f8c\64f0e4b3_4a53cf01\TestBridge.dll.
LOG: Assembly is loaded in default load context.
You may need to enable 64 bit IIS Express support as part of VS 2013 / 2015 / 2017:
Tools -> Options -> Projects and Solutions -> Web Projects -> Use the
64 bit version of IIS Express
Credit to the response in this question
Try the following:
Fusion Log for better error message: http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx
Ensure App Pool is 4.0
Go to App Pool Settings in IIS and check if 'Enable 32 bit applications' is true
If Fusion Log shows that everything is peachy, then it might be a problem with a dependent module which is unmanaged.. use SysInternal's ProcMon utility to see if that reports any issues.
another issue is checking the VC++ 11 runtime on the machine.. some machines have it installed and some don't.
Check the CPU (any cpu, x86 vs 64 again) just to be sure.
I had a old application running in asp which was migrated to .net recently and was deployed on Windows 2008 server but it was still being run in 32 bits due to some dll (old MSXML dll was being used) dependency.
The dependency was removed and it was rebuild on 2012 VS. When I deploy and change the app pool setting to disable 32 bit application flag (under advanced settings), it gives me following error.
However if i change the flag to true the application starts working again.
Can anyone suggest some solution please?
---------------------------------------------------------------------------------------
Could not load file or assembly 'System.Web' or one of its dependencies. An attempt was made to load a program with an incorrect format.
---------------------------------------------------------------------------------------
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\*******\******\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/70aa83e0/80464c61/System.Web.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/70aa83e0/80464c61/System.Web/System.Web.DLL.
LOG: Attempting download of new URL file:///D:/Websites/XML_NET/bin/System.Web.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.