1

I'm getting the below error on a brand new production machine running windows server 2016. The below dll is from a nuget reference from Spitfire (https://github.com/RainwayApp/spitfire). The exact same code runs perfectly fine on my Windows 10 dev machine.

How do I figure out what is wrong on the production machine?

System.IO.FileNotFoundException: Could not load file or assembly 'Spitfire.dll' or one of its dependencies. The specified module could not be found.
File name: 'Spitfire.dll'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Owin.Loader.DefaultLoader.AssemblyDirScanner.<GetEnumerator>d__1e.MoveNext()
   at Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict)
   at Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors)
   at Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails)
   at Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails)
   at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp(StartContext context)
   at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
   at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(StartOptions options)
   at Communication.WebRTC.WebRTCHandshaker.WebRTCLoop(String url) in F:\SW\DedicatedServer\Communication\WebRTC\WebRTCHandshaker.cs:line 56

Update 1

Used .NET assembly dependency walker on the spitfire.dll. on my LOCAL machine Got this result. Nothing sticks out to me. Doing the production server shortly and will update. enter image description here

Update 2:

Not sure what I'm supposed to be seeing, but this is from the production server. enter image description here

Update 3:

Printing the below values both yield the correct values to the working folder or exe on the production server.

System.Reflection.Assembly.GetEntryAssembly().Location.ToString()
Environment.CurrentDirectory
JensB
  • 6,663
  • 2
  • 55
  • 94
  • Did you copy Spitfire.dll to the production machine with your application? – Gabriel Luci Nov 05 '18 at 20:05
  • 1
    Check if there is a property on this file on Solution Explorer, copy to output directory. – Tony Nov 05 '18 at 20:08
  • Its there. Its been copied. The exact same exported build folder runs on my dev machine. Then I copy the entire folder over and get the above on the other computer – JensB Nov 05 '18 at 20:16
  • 1
    You will get much better diagnostic information if you can [turn on assembly bind failure logging](https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net) – John Wu Nov 05 '18 at 20:42
  • @JohnWu I am now running Fuslogvw.exe on the server and configured it according to https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net/3256753#3256753 but I'm not getting any logs at all to it. No failures. – JensB Nov 05 '18 at 20:53

3 Answers3

2

This usually happens when one of the dependencies fails to load.

Check for a .NET assembly dependency walker (e.g. depends.net) and check the DLL. You need to run this check on the production server.

Marcel
  • 1,688
  • 1
  • 14
  • 25
2

How are the binaries deployed on the production machine? Are you using an installer? Is the dll packaged in the installer? Can you see the dll in the install path for your application?

Update: Most likely the Environment.CurrentDirectory under which the application is run is not the application install path on the production server. Write the Environment.CurrentDirectory to a console/log file and compare the output to the install directory.

See this question if you need to find the install path of your application during runtime.

Alexander Pope
  • 1,134
  • 1
  • 12
  • 22
  • 1
    I build a release version of the program. Zip the release folder. Copy it to the server. But when copied over to the server the above error gets thrown. If I place the same release folder on some other location on my dev computer and start it it runs fine. – JensB Nov 05 '18 at 20:19
  • Write the output of "Environment.CurrentDirectory" to a log file and see if it matches to install path. The CurrentDirectory could be different than the install path. – Alexander Pope Nov 05 '18 at 20:23
  • Also, you can use System.Reflection.Assembly.GetExecutingAssembly().Location to find the install path of your application at runtime – Alexander Pope Nov 05 '18 at 20:24
  • The application is not installed. Its all just one copied folder with all files in it. Exact same thing that works on my local dev machine. I can copy the folder to any place on the dev machine and run it without issue. – JensB Nov 05 '18 at 20:31
  • Install path is just the path to your executable on the prod machine. I'm 90% sure the issue is due to an unexpected CurrentDirectory when running the app in prod. – Alexander Pope Nov 05 '18 at 20:37
  • See update, both values are correct. Tried copying the file to C:\Program Files\Release just to test it in a different location its showing the correct location both times. – JensB Nov 05 '18 at 20:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183149/discussion-between-alexander-pope-and-jensb). – Alexander Pope Nov 05 '18 at 20:58
0

The problem was missing VC++ redistributable. After installing vc_redist.x64.exe everything worked.

JensB
  • 6,663
  • 2
  • 55
  • 94