How to solve "System.IO.FileNotFoundException" in Windows? - windows

I'm facing the following error message:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Application Server Core,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified.'
This means that the file "Application Server Core.dll", version 1.0.0.0, is not present in a runtime directory.
A runtime directory?
Yes: I have an application in one directory and a bunch of DLLs in another one. But that's not the main issue.
The point is that I'm working in a client environment, which means that the "Application Server Core" should even not be loaded.
So, I'm asking which other application or DLL is trying to load this DLL. I can't find out while checking the callstack, so I thought having a look inside the other applications or DLLs, using the Windows equivalent of the ldd or the nm UNIX/Linux commands, and you can already guess my question:
What are the Windows equivalents for the UNIX/Linux ldd and nm commands?
Thanks in advance

Related

Application exe not running properly. There is a log in CLR_v4.0_32\UsageLogs. What does this mean?

I have an EXE application we use that is very important. On some PC's it runs fine -- some it doesn't. I have seen it work on fresh install of Win7x64 -- after installing the 180 updates it no longer runs properly.
I upgraded to Windows 10 and it ran fine. Had a hardware problem and had to reinstall the OS. After doing drivers,updates,etc the application won't run.
I found a log file in: C:\Users\username\AppData\Local\Microsoft\CLR_v4.0_32\UsageLogs
1,"fusion","GAC",0
1,"WinRT","NotApp",1
3,"System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System\08da6b6698b412866e6910ae9b84f363\System.ni.dll",0
3,"System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Core\f6ebd52be27fe627fed0d185c6a9c0d5\System.Core.ni.dll",0
3,"Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","C:\windows\assembly\NativeImages_v4.0.30319_32\Microsoft.V9921e851#\02386c57c46556747a75089068a31af0\Microsoft.VisualBasic.ni.dll",0
3,"System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Drawing\c2abcda8f96d67fa6ff5665fd21dddff\System.Drawing.ni.dll",0
3,"System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Windows.Forms\c02fbf560e52a1aab432a90d4c613af4\System.Windows.Forms.ni.dll",0
3,"System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","C:\windows\assembly\NativeImages_v4.0.30319_32\System.Runt73a1fc9d#\272d1cf3a7cbd4cd648a2ff2d7a8889a\System.Runtime.Remoting.ni.dll",0
I can't find much information on why these logs are created and if this shows any useful information as to why it's not running properly. The application is not supported so I'm trying to get it to run until we have another solution.
I think this log file has nothing related to the issue that your application "doesn't run fine".
You should build in your application your own kind of tracing to locate the issue, what kind of exception is raised? Could you provide maybe more information about whats going wrong?
Here are some information about the log file mentioned above:
With Windows 8 (.NET 4.5), a new NGen mode: "Auto NGen" has been
introduced. Basically, the .NET runtime generates usage logs for
managed applications. Source
Every time the application run it creates a new type of logs called
“Assembly Usage Logs” in the AppData windows directory.
Source
On my research I found out mostly that it only does this job on Windows 8+.
But in this source it says also on Windows Server 2012, but I have tried it on a Windows Server 2012 R2 and could NOT reproduce it!

Could not load file or assembly Microsoft.mshtml

I have a program in c# that is using WatiN. It compiles and runs well in my development windows 7. However when I copy the program to windows 2012 datacenter in azure, it throws below exception when the application tries to start an instance of internet explorer(which exists in windows 2012 datacenter):
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified. File name: 'Microsoft.mshtml,
Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at
WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout()
at WatiN.Core.IE.WaitForComplete(Int32 waitForCompleteTimeOut) at
WatiN.Core.Browser.GoTo(Uri url) at
WatiN.Core.IE.FinishInitialization(Uri uri)
I am kind of lost on this exception, what is missing on the server?
Thank.
It is a standard interop assembly that is installed in the GAC on any dev machine. Not exactly sure how it got there, most likely it is the VS installer that put it there. But it won't be in the GAC on that Azure node.
Open the References node of your project and select the Microsoft.mshtml entry. Change the Copy Local property to True. Rebuild and you'll now have a copy of the assembly in your build directory. Copy it along with the rest of your executables to the Azure node.

NGEN'd assemblies not being loaded

I'm trying to measure the performance impact of NGENing my assemblies versus not but I am unable to get my executable to load the NGEN assemblies. I ran the following from the VS2010 command prompt:
ngen install MyApp.exe
This completed without any issues and I verified that all my dependency assemblies had been created in the C:\Windows\assembly\NativeImages_v4.0.30319_32\MyCompanyName# directory.
I then launched my app and looking at Process Explorer, it was loading all my assemblies from the local binaries directory instead of loading the *.ni.dll files from the NativeImages_x folder. I logged the bindings using fuslogvw. Here is a sample log entry:
*** Assembly Binder Log Entry (6/29/2011 # 10:14:04 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:\Path\To\My\Binaries\MyCompanyName.MyApp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = username
LOG: DisplayName = MyCompanyName.MyAssembly, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Path/To/My/Binaries/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyCompanyName.MyApp.exe
Calling assembly : MyCompanyName.AnotherAssembly, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image MyCompanyName.MyAssembly, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null.
WRN: No matching native image found.
LOG: IL assembly loaded from C:\Path\To\My\Binaries\MyCompanyName.MyAssembly.dll
Does anyone have any thoughts on what is going on here? I verified that the native assembly in question exists at:
C:\Windows\assembly\NativeImages_v4.0.30319_32\MyCompanyName#\3a041121abf7fbdce89836c32f2d217e\MyCompanyName.MyAssembly.ni.dll
Why isn't it binding it correctly? FWIW, the application uses MEF quite a bit; I don't know if that would affect the loading of the assemblies.
It's because of using MEF. NGEN is only able to follow assembly references. But if you use MEF then you probably don't refer all the assemblies because MEF is responsible to load them dynamically at runtime.
Your approach is the right one. Call all assemblies with NGEN.
ngen install c:\myfiles\MyLib.dll /ExeConfig:c:\myapps\MyApp.exe
In this case you need to remove these assemblies manually from the cache when the application is uninstalled.
ngen uninstall c:\myfiles\MyLib.dll /ExeConfig:c:\myapps\MyApp.exe
See also: http://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.100).aspx
I don't know what the actual issue was but the solution was to write a batch file that simply NGEN'd every binary in the directory. I guess there were binaries that were not being NGEN'd when running just the ngen install command on the top-level exe.

Error building project with XNAnimationPipline.dll and XNA3.1

I have a model with 2 animations, created in Blender and exported to fbx.
Referencing the XNAnimation.dll works, however when I reference the XNAnimationPipline.dll in the Content project I get a build error.
The "BuildContent" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'XNAnimationPipeline, Version=0.7.0.0, Culture=neutral, PublicKeyToken=0c21691816f8c6d0' or one of its dependencies.
The system cannot find the file specified.
File name: 'XNAnimationPipeline, Version=0.7.0.0, Culture=neutral, PublicKeyToken=0c21691816f8c6d0'
I have recently upgraded to XNA3.1 and am using the latest XNAnimation library.
Any ideas?
Thanks
Rebuilding the source code sorts it out
This explains

Caching Application Block Error

Has anyone seen this error before?
An error occurred creating the configuration section handler for cachingConfiguration: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (C:\WorkingDir\Projects\ReportCentral\ReportCentral\bin\Debug\ReportCentral.vshost.exe.config line 5)
I am using Ent Lib 4.0. I changed my App Traget Framework from 2.0 to 3.5.
Edit ~
I have the following in the bin
Caching.dll
Common.dll
ObjectBuilder2.dll
Edit ~ "Solution"
This was the deal, when referencing dlls in the C:\EntLib4Src\bin, they are signed and could only be configured by the EntLibConfig.exe found in that same folder and not the one from "Start>Programs>Microsoft Patterns...>Ent Wasn't that tricky?
That means it can't find the file. So you either need to put it into the GAC or the bin folder so that the assembly can be loaded.
This was the deal, when referencing dlls in the C:\EntLib4Src\bin, they are signed and could only be configured by the EntLibConfig.exe found in that same folder and not the one from "Start>Programs>Microsoft Patterns...>Ent Wasn't that tricky?

Resources