System.Io.FileNotFoundException for System.Core when using Ninject in .Net 3.5
I am using Ninject (v3.2.2.0) with a tool built on top of .net 3.5. It was fine until a couple of weeks ago when I put development on hold.
I put it back together to prepare for release and it is no longer ok - it still compiles without issue, but now I get a FileNotFoundException when I try to run it:
Fixed System.IO.FileNotFoundException Message = Could not load file or assembly "System.Core, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e" or one of its dependencies. The system cannot find the file specified. Source = Ninject FileName = System.Core, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e FusionLog = Assembly manager loaded from: C: \ Windows \ Microsoft.NET \ Framework64 \ v2.0.50727 \ mscorwks.dll Run on executable file E: \ work \ wire \ M \ Tools \ Import \ bin \ Debug \ Import.vshost.exe --- The following is a detailed error log.
=== Pre-bind status information ===
LOG: User = ZOO \ TAL LOG: DisplayName = System.Core, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e (Fully specified) LOG: Appbase = file: /// E: / work / wire / M / Tools / Import / bin / Debug / LOG: initial PrivatePath = NULL Assembly call: Ninject, Version = 3.2.0.0, Culture = neutral, PublicKeyToken = c7192dc5380945e7.
LOG: This binding starts in the default load context. LOG: Using application configuration file: E: \ work \ wire \ MR \ Tools \ Import \ bin \ Debug \ Import.vshost.exe.Config LOG: Using machine configuration file from C: \ Windows \ Microsoft.NET \ Framework64 \ v2 .0.50727 \ config \ machine.config. LOG: Post-Policy Link: System.Core, Version = 2.0.5.0, Culture = neutral, PublicKeyToken = 7cec85d7bea7798e LOG: Attempting to download a new file URL: /// E: / work / wire / M / Tools / Import / bin / Debug / System.Core.DLL. LOG: Attempting to download a new file URL: /// E: /work/wire/M/Tools/Import/bin/Debug/System.Core/System.Core.DLL. LOG: Attempting to download a new file URL: /// E: /work/wire/M/Tools/Import/bin/Debug/System.Core.EXE. LOG: Attempting to download a new file URL: /// E: /work/wire/M/Tools/Import/bin/Debug/System.Core/System.Core.EXE.
StackTrace: in Ninject.Planning.Bindings.BindingConfiguration..ctor () in Ninject.Planning.Bindings.Binding..ctor (service type) in Ninject.Syntax.BindingRoot.BindT in Ninject.KernelBase..ctor (IComponentContainer components, settings INinjectSettings, modules INinjectModule []) in modules Ninject.StandardKernel..ctor (INinjectModule []) in Import.ImportBootstrapper.Import (String [] xiArgs) in e: \ work \ wire \ M \ Tools \ Import \ ImportBootstrapper.cs: line 16 InnerException:
I've taken this to the extreme - I'm currently trying to run only the following code:
using Ninject;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
new StandardKernel();
}
}
}
Which again, compiles just fine, but as soon as I get to the line new StandardKernal();
it breaks with the same error as above.
It's also all in source control, so I uploaded this to colleagues system, links, libraries, configs and everything and yep, it works fine on my machine.
To fix this I have:
-
Make sure the referenced System.Core file exists (it does this).
-
Make sure it has the correct permissions.
-
Make sure System.Core definitely exists in the GAC - it did it and the results are below:
C:\> gacutil -l | find /i "system.core" System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL
-
In "Turn Windows features on or off", uninstalled .NET Framework 3.5, rebooted, reinstalled .NET 3.5, rebooted again, tried to run the program.
-
All available Windows updates installed (.NET first, but eventually all of them).
-
Tried to find problems with
sfc /scannow
so as not to be influenced. -
Interoperability with different supported Runtime versions in the App.config file:
<configuration> <startup> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v3.5.30729"/> </startup> </configuration>
(Having either, both, or neither of them makes a noticeable difference)
-
Make sure the Reference files are definitely included with System.Core (
<Reference Include="System.core" />
). -
Make sure the project properties are definitely set to .Net 3.5.
-
I also looked into the machine.config and web.config files. It's nothing to blame, but I'm not sure I can determine if something was clearly wrong, so I can't say that this path of investigation is closed.
Now I am completely at a loss. I mean not to get a new computer out of there too.
What am I doing wrong?
source to share