3

I'm using Ninject (v3.2.2.0) with a tool built on a .net 3.5 framework. This had been fine - up until a couple of weeks ago when I put aside development.

I've picked it up again to prepare for the release, and it is no longer fine - it still compiles without issue, but I now get a FileNotFoundException whenever I try to run the it:

System.IO.FileNotFoundException occurred 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 Running under executable E:\work\wire\M\Tools\Import\bin\Debug\Import.vshost.exe --- A detailed error log follows.

=== Pre-bind state 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 Calling assembly : Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7.

LOG: This bind starts in 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 reference: System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e LOG: Attempting download of new URL file:///E:/work/wire/M/Tools/Import/bin/Debug/System.Core.DLL. LOG: Attempting download of new URL file:///E:/work/wire/M/Tools/Import/bin/Debug/System.Core/System.Core.DLL. LOG: Attempting download of new URL file:///E:/work/wire/M/Tools/Import/bin/Debug/System.Core.EXE. LOG: Attempting download of new URL file:///E:/work/wire/M/Tools/Import/bin/Debug/System.Core/System.Core.EXE.

StackTrace: at Ninject.Planning.Bindings.BindingConfiguration..ctor() at Ninject.Planning.Bindings.Binding..ctor(Type service) at Ninject.Syntax.BindingRoot.BindT at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) at Ninject.StandardKernel..ctor(INinjectModule[] modules) at Import.ImportBootstrapper.Import(String[] xiArgs) in e:\work\wire\M\Tools\Import\ImportBootstrapper.cs:line 16 InnerException:

I've taken this to its 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 new StandardKernal(); line it breaks with the same error as above.

It's also all in source control, so I've loaded this up on a colleague's system, references, libraries, configs and all, and yep, it runs fine on their machine.

To try and fix this, I have:

  1. Made sure that the referenced System.Core file exists (it does).

  2. Made sure that it has the correct permissions.

  3. Ensured that System.Core definitely existed in GAC - it did, 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
    
  4. In "Turn Windows features on or off", removed .NET Framework 3.5, rebooted, reinstalled .NET 3.5, rebooted again, tried to run the program.

  5. Installed all available windows updates (initally the .NET ones, but eventually all of them).

  6. Tried to find issues with sfc /scannow, to no effect.

  7. Tinkered with various supportedRuntime 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 makes no discernible difference)

  1. Made sure that the Reference files definitely included System.Core (<Reference Include="System.core" />).

  2. Made sure that the project properties are definitely set to .Net 3.5.

  3. I've also looked into the machine.config and web.config files. Nothing looked at fault, but I'm not sure I'd be able to identify if something was obviously wrong, so I can't say that this avenue of research is closed off.

I'm now completely at a loss. I mean, short of getting a new PC and starting from there.

What am I doing wrong?

Tim L
  • 141
  • 9
  • Just a thought: you say .NET 3.5 but the log says version 2 (v2.0.50727)? – Christian May 29 '15 at 19:50
  • 1
    Yes - I've so far been assuming that it's referring to the runtime version (which indicates the version of the CLR - and .NET Framework 3.5 still uses CLR 2.0(.50727)). That said, it's completely possible that I'm wrong about that. If I am wrong, how would I go about fixing it? Visual Studio definitely thinks everything is using .Net 3.5. – Tim L May 29 '15 at 20:00
  • You're right, [.NET 3.5 uses CLR v.2.0](https://msdn.microsoft.com/en-us/library/bb822049%28v=vs.110%29.aspx). [This issue](http://stackoverflow.com/questions/23903657/could-not-load-file-or-assembly-system-version-2-0-5-0-in-net-4-mvc-4-applicat) seems to be related but I guess you've already done a fair amount of searching? – Christian May 29 '15 at 20:42
  • Yep. Sadly, that issue seemed to be solved by installed Microsoft silverlight (which hasn't helped me). I feel mine must be related, but none of their solutions are particularly relevant. – Tim L Jun 01 '15 at 09:51

1 Answers1

0

Add Website with new Application Pool. We faced the same issue and fixed by creating a new website and application pool in IIS.

Nikki Punjabi
  • 383
  • 2
  • 16