I have a C# class which calls a .Net assembly built from a Matlab function. I am able to call this function from a simple C# console application with no problems.
However if I try to run a unit test from NUnit I get the following exception:
ClassLibrary1.Tests.UnitTests.TestPerformOptimization:
System.Reflection.TargetInvocationException : Exception has been
thrown by the target of an invocation. ----> System.Exception :
Error marshalling .NET object. 'Message: Unable to find assembly
'ClassLibrary1, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'. Source: mscorlib HelpLink: '
I get the same error if I try to call the class from either the standalone NUnit console, from ReSharper's test runner or if I try to call the function from say Excel (using Excel-DNA).
When calling my compiled Matlab component I actually wrap up a C# method (in an MWObjectArray object) and inject it in. I think the problem is happening when the compiled Matlab component tries invoking this injected method.
The only workaround I've found is to simply place a copy of my class (containing the method that is injected) in the same location as the NUnit test runner, the ReSharper test runner or Excel. However this is simply not a practical solution going forward as I need to install this application onto users machines. The other option which I can't use is copying the files to my %DEVPATH% for the same reason.
Is there a way I can tell the Matlab component where to find the assembly of my injected method/class?
SAMPLE PROJECT DOWNLOAD
There is a sample project available for download here. Just follow the instructions in the README.txt file located in the zip file.
Update 1
I manage to get my unit test to recognise my assembly by modifying my class to include the following in its constructor:
AppDomain.CurrentDomain.AssemblyResolve +=
(sender, args) => typeof(OptimizationFunction).Assembly;
However now I get the following exception:
Exception: System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. ---> System.Exception:
Error marshalling .NET object. 'Message: Could not load file or
assembly 'dotnetcli, Version=1.0.5488.33915, Culture=neutral,
PublicKeyToken=da1231a838c93da4' or one of its dependencies. A
strongly-named assembly is required. (Exception from HRESULT:
0x80131044) Source: mscorlib HelpLink: ' at
dotnetcli.throwNetExceptionID(BaseMsgID* msgId) at
dotnetcli.DeployedDataConversion.GetMxArrayFromObject(Object data)
--- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
So now it has a problem resolving the dotnetclli.dll (See Fusion log/exception below) which as far as I know should reside only in C:\Program Files (x86)\MATLAB\MATLAB Runtime\v85\bin\win32.
Here's an excerpt from the Fusion Log:
=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary1 (Partial)
WRN: Assembly Name: ClassLibrary1 | Domain ID: 1
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:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = nunit-agent-x86.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file:
C:\Insight\TFS\Asg\ConsoleApplication4\packages\NUnit.Runners.2.6.3\tools\nunit-agent-x86.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:/XXXXX/ConsoleApplication4/packages/NUnit.Runners.2.6.3/tools/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/ClassLibrary1/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/lib/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/lib/ClassLibrary1/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/addins/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/addins/ClassLibrary1/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/ClassLibrary1/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/lib/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/lib/ClassLibrary1/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/addins/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///C:/XXXXX/ConsoleApplication1/packages/NUnit.Runners.2.6.3/tools/addins/ClassLibrary1/ClassLibrary1.EXE.
LOG: All probing URLs attempted and failed.
WRN: Partial binding information was supplied for an assembly: How come my console app can resolve this assembly by my NUnit test cannot?
Update 2
I got the following response from Matlab when I contacted them:
As far as I know this is the default .NET behavior when it comes to
deserializations. The application which deserializes the class looks
for the assembly in its own current folder and GAC where it cannot
find it. It is similar to (when you read this replace MATLAB with
Nunit)
http://www.mathworks.com/matlabcentral/answers/101695-why-can-my-assembly-not-be-found-when-deserializing-a-net-object-in-matlab-7-10-r2010a
You example does not represent the situation when MATLAB is involved.
MATLAB sends the class across APPDomains. Your example does not do
that.
Use Fuslogvw to have a look at the binding. You will see that it is
not MATLAB which cannot find the assembly it’s the calling application
which is unable to resolve the dependency (in your case
nunit-agent-x86.exe).
Make sure all needed files are produced by the compilation of ConsoleApplication4 and placed besides the executable (e.g. any needed assembly DLL, runtime DLL, .config file, etc.)
Once you are sure this happens, start NUnit with the --no-shadow-copy command line switch, or set it as a configuration parameter from your GUI tool. As Bush said, NUnit usually copies the files under test to a separate directory, and may leave behind important files.
If the class created by Matlab needs some sort of specific runtime, make sure it is correctly installed in the computers where you are running the tests / using Excel/ReSharper.
I would not try to fiddle, at this level, with the Assembly resolution process: please sum up the content at the article you linked, because it's paywalled, and try with NUnit's no-shadow-copy setting.
A propos first problem:
Run regedit
go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion
Add DWORD ForceLog = 1
Add DWORD LogFailures = 1
Add DWORD LogResourceBinds = 1
Add String LogPath = C:\log\ (last \ must be there)
Create a directory for logs (c:\logs for example)
It will log where your app looked for assemblies and how it failed. It probably means that working directory of nunit was different from working directory used by your console application.
A propos second error: strongly named assembly is required means that the library you have tried to use was not signed. If it's your assembly you simply have to use visual studio's sign the assembly from project properties. If it's not your assembly you can decompile it and compile it with strong name (with this method), but provider of third party dll should give you a strong-named assembly.
My guess this issue comes from an .NET CLR version incompatibility. Some client's (I mean client who calls your assembly) loads different versions of the CLE, then the resolved assembly may incompatible with that loaded CLR. This could cause not found error, because a compatible assembly really not found.
Try to check/play with both client's versions (the console app) and the server's version (your assembly) and diagnose what is changing.
Also check your assembly reference has "Copy to the output directory" is checked in all projects
You will want to study how the probing operation happens at .NET load time. Here's the rules for that: https://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.110).aspx
Outside of including the bin in the assembly you are publishing, it's the loader that decides if the support cast of DLLs are loadable. If it cannot find it using the rules above then you are simply out of luck.
We have seen issues similar to this in the past, some developer says to system admin, here's the Dlls you need to get the app running. System Admin follows instructions and boom, the application fails at load time.
Reason: Some child of a child in the assembly referred to a dll that's NOT on the system based on the probing rules.
Solution
1) Get the (child of the child) dll to include all dependencies in its assembly
2) Change the newer Main assembly to include all the dependencies (if the children assemblies cannot be changed).
3) Manually copy them in.
4) Create an installer that does it all.
Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.
My guess this issue comes from an .NET CLR version incompatibility. Some client's (I mean client who calls your assembly) loads different versions of the CLE, then the resolved assembly may incompatible with that loaded CLR. This could cause not found error, because a compatible assembly really not found.
Try to check/play with both client's versions (the console app) and the server's version (your assembly) and diagnose what is changing.
Also check your assembly reference has "Copy to the output directory" is checked in all projects
Related
I have a WPF exe that after being built, if the exe is renamed, will not run because a FileNotFoundException is thrown. I have never seen this in ten years of working with .NET executables and this is not supposed to be a problem. Our exe name is built as "Installer.exe", but if we rename it to anything else and try to run it it fails with the following call stack:
Application: test.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
at System.Reflection.RuntimeAssembly._nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, IntPtr, Boolean, Boolean, Boolean)
at System.Reflection.Assembly.Load(System.Reflection.AssemblyName)
at System.Windows.Navigation.BaseUriHelper.GetLoadedAssembly(System.String, System.String, System.String)
at MS.Internal.AppModel.ResourceContainer.GetResourceManagerWrapper(System.Uri, System.String ByRef, Boolean ByRef)
at MS.Internal.AppModel.ResourceContainer.GetPartCore(System.Uri)
at System.IO.Packaging.Package.GetPartHelper(System.Uri)
at System.IO.Packaging.Package.GetPart(System.Uri)
at System.Windows.Application.GetResourceOrContentPart(System.Uri)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at Installer.App.InitializeComponent()
at Installer.App.Main()
If I debug the executable I can further expand that to:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Installer, Version=1.0.0.0,
Culture=neutral' or one of its dependencies. The system cannot find the file specified.'
I have also investigated the Fusion Log:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Users\dande\Downloads\test.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Installer, Version=1.0.0.0, Culture=neutral
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Installer, Version=1.0.0.0, Culture=neutral | Domain ID: 1
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:///C:/Users/dande/Downloads/
LOG: Initial PrivatePath = NULL
Calling assembly : PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
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: 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/dande/Downloads/Installer.DLL.
LOG: Attempting download of new URL file:///C:/Users/dande/Downloads/Installer/Installer.DLL.
LOG: Attempting download of new URL file:///C:/Users/dande/Downloads/Installer.EXE.
LOG: Attempting download of new URL file:///C:/Users/dande/Downloads/Installer/Installer.EXE.
And I have investigated and ruled out the following:
We are not using Assembly.Load to load 'Installer' (which is the executing assembly)
We do not have any pack:// usages in XAML.
We have no code analysis warnings, errors, or XAML errors
It is not related to a application configuration file
It is not related to the application manifest
Application crashes even if I change the code to use a normal Window and not our MainWindow (eliminating a lot of XAML from the equation)
.NET version doesn't make a difference. It's targeting and built for .NET 4.6, but changing this doesn't change the outcome
Confirmed that all dependencies are referenced/present using DotPeek/JustDecompile
Confirmed that all namespaces internally are still 'Installer'
Investigated the partial binding via reading documentation, but this isn't a reference issue, the error indicates its the executing assembly itself that is the issue (it's looking for itself?)
Is not related to code signing as it occurs with or without it
It is not related to strong name signing as we are not using that
Changing the project properties assembly output name but leaving the namespace as Installer works and presents no issues
Things I have observed:
This happens prior to OnStartup. I cannot debug into the application.
It appears to be PresentationCore.dll (from Fusion Log) originating this issue
Confirmed with ProcMon.exe that it is in fact trying to access one of the four logged fusion log paths (Installer.DLL, Installer/Installer.DLL, Installer.EXE, Installer.Installer.EXE)
This occurs on any environment and I can reproduce locally by building the solution then renaming, the output file and then running it
If I copy the executable and rename that and run it it works fine because Installer.exe is present in the same directory
I have never seen this problem before and researching it I have not been successful because I'm just finding all the basic stuff new developers typically run into with reference problems and the like.
My only assumption is that possibly its XAML related but I haven't found anything in XAML out of the ordinary and we don't have any pack:// usages or anything.
Only way we managed to solve this was by adding an AssemblyName attribute to the .csproj file with the name of the assembly after renaming. That way you wouldn't have to do the rename anymore yourself.
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've got a simple .NET application written in C#, which links with a C++/CLI DLL
which is itself just a thin wrapper around a C++ static library.
The app runs fine on the development machine (Windows 8), but, when the EXE and
DLL are copied over to another machine (Windows 10) it crashes immediately on
startup.
Looking in Event Viewer, I can see that the crash is due to an unhandled
exception, System.IO.FileNotFoundException, and the call-stack indicates that
the exception occurs in a function that makes a call into the DLL.
If I edit the function in the DLL to return immediately, then the crash still
occurs. Adding a try-catch block around the call also has no effect. However,
if I remove the call entirely, then the application runs.
The app runs fine on the development box, even if I move the EXE and DLL to a
different location. However, if I delete the DLL from the directory in which the
EXE is located, then exactly the same crash occurs.
This suggests that the problem is that the app cannot find the DLL when run on
the other machine.
The projects for both the application and the DLL are included in the same
Visual Studio 2015 solution, and the application is linked to the DLL via a
project reference.
The application targets .NET 4.5.2, and the other machine has .NET 4.6
installed. The only other references in the application project are to parts of
.NET, such as Microsoft.CSharp and System.Core.
How can I fix this crash?
EDIT: As suggested by #Alex K. in the comments, I tried logging bind failures with fuslogvw.exe, which garnered the following log excerpt:
*** Assembly Binder Log Entry (08/04/2016 # 14:47:02) ***
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 D:\[Path]\[App Name].exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = [DLL Name], Version=1.0.5941.28221, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///D:/[Path]/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = [App Name].exe
Calling assembly : [App Name], Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
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: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///D:/[Path]/[DLL Name].DLL.
LOG: Attempting download of new URL file:///D:/[Path]/[DLL Name]/[DLL Name].DLL.
LOG: Attempting download of new URL file:///D:/[Path]/[DLL Name].EXE.
LOG: Attempting download of new URL file:///D:/[Path]/[DLL Name]/[DLL Name].EXE.
LOG: All probing URLs attempted and failed.
So it seems that the file that cannot be found is my DLL, and that .NET is
indeed looking in the correct location for the file, but for some reason it is
not finding it there.
Note that I obtained the same error log on my development machine when I attempted to run the EXE with the DLL deleted.
As discussed in the comments, I tried installing the Visual C++ 2015 Redistributable. This didn't appear to have any effect at the time. However, a couple of days later, the problem is no longer reproducible, and I can't think of anything else that would have fixed it. (The Redistributable installer didn't request a reboot, but my best guess is that one was actually required.)
I am using the Magick.net library in an mvc3 web application and these are steps i did
My project is targeting AnyCPU and my machine is 64bit
Add reference of Magick.NET-x64.dll to the project.
Installed Visual C++ Redistributable for Visual Studio 2012 Update 4 from here http://www.microsoft.com/en-us/download/details.aspx?id=30679
Installed Ghostscript 9.14 for Windows (64 bit) on machine
Added
<add assembly="Magick.NET-x64, Version=7.0.0.0002, Culture=neutral, PublicKeyToken=2004825badfa91ec" />
on web.config file
Project is rebuilded successfully [and all dlls are in bin folder also], but while running i am getting the exceptions
Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.
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.BadImageFormatException: Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was > made to load a program with an incorrect format.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Magick.NET-x64' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Magick.NET-x64
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Magick.NET-x64 | Domain ID: 6
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:///C:/Fagbokforlaget/SourceCodes/fbf_internal/picsilo/Source/ImageTagger/
LOG: Initial PrivatePath = C:\Fagbokforlaget\SourceCodes\fbf_internal\picsilo\Source\ImageTagger\bin
Calling assembly : (Unknown).
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Fagbokforlaget\SourceCodes\fbf_internal\picsilo\Source\ImageTagger\web.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/jibinmathew/AppData/Local/Temp/Temporary ASP.NET Files/root/a5b5e44f/dc1c4c69/Magick.NET-x64.DLL.
LOG: Attempting download of new URL file:///C:/Users/jibinmathew/AppData/Local/Temp/Temporary ASP.NET Files/root/a5b5e44f/dc1c4c69/Magick.NET-x64/Magick.NET-x64.DLL.
LOG: Attempting download of new URL file:///C:/Fagbokforlaget/SourceCodes/fbf_internal/picsilo/Source/ImageTagger/bin/Magick.NET-x64.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
A revision to the blog post sited by #dlemstra has the easiest solution I've found for this:
In VS2013/2015, go to Tools --> Options --> Projects and Solutions --> Web Projects and select "Use the 64 bit version of IIS Express for web sites and projects."
There seems to be a problem when running the 64 bit version of Magick.NET in Visual Studio 2013's IIS Express. You need to set a registry key according to the following answer 'High quality JPEG compression with c#'. You could set this flag or switch to the AnyCPU version of Magick.NET.
Make sure redistributable C++ package is also installed.
https://magick.codeplex.com/documentation
Make sure you have installed Visual C++ Redistributable for Visual
Studio
.NET 4.0: Visual C++ Redistributable for Visual Studio 2015 (x64 or x86)
.NET 2.0: Visual C++ Redistributable for Visual Studio 2008 (x64 or x86).
Does anyone have any idea what would cause the Fusion loader to simply skip over a DLL with no warning or acknowledgement?
When I attempt to do this (in C#) from a command-line application
Assembly.LoadFrom("c:\\Deploy\\bin\\WebServices.dll")
I see this:
"Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
That DLL has a dependency on Platform.DLL, but the loading of that dependency fails so this line of code throws an exception. When I check the Fusion assembly loading message, this is what I see:
=== Pre-bind state information ===
LOG: DisplayName = Platform, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null (Fully-specified)
...
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
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:/Project/bin/Debug/Platform.DLL.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform/Platform.DLL.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform.EXE.
LOG: Attempting download of new URL file:///C:/Project/bin/Debug/Platform/Platform.EXE.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform.DLL.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform/Platform.DLL.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform.EXE.
LOG: Attempting download of new URL file:///c:/Deploy/bin/Platform/Platform.EXE.
The thing is, the DLL is present at c:\Deploy\bin\Platform.DLL, with proper version and no signed public key.
Things I've thought of:
1. Maybe it's really a dependency of Platform.DLL that's broken, causing this behavior? (I chased the dependency tree in Reflector but found no missing DLLs)
2. Maybe there's a release/debug mismatch, or a 64-bit vs 32-bit? but everything was built on the same machine
3. Maybe I'm misreading the logs, but shouldn't it stop when it hits a DLL that it finds? I don't see either the "successful" OR the "unsuccessful" message in this log. I just know it failed because of the exception.
PS more tech details:
Machine environment is Windows 2008 64-bit, with .NET 2.0, 3.0 & 3.5 installed.
This same application runs just fine on another machine (Vista 32-bit), with the same directory structure and DLLs, although those were built on that machine
Yep it should stop when it finds the required dll so the fifth "Attempting to download..." should have found it...
However where is the command line app being run from? If it's the Debug folder then a few things you can try are
Have the dependent dll's in the same folder
Sign the assembly and reference through a .config file in the following format
<dependentAssembly>
<assemblyIdentity name="WebServices.dll" publicKeyToken="<whatever this public key it>" />
<codeBase version="1.0.0.0" href="..\WebServices.dll" />
</dependentAssembly>
Sign them and then put the dependent assemblies in the GAC.
I might be way off but that's a few things to try.