0

I was trying to get a library that required System.Threading.Dll to work with my .NET 3.5 web application project. Since 3.5 doesn't have System.Threading.Dll, I followed a tip to install the Reactive extensions because it has a backported version of System.Threading for 3.5.

The attempt still failed and after enough frustration I backed out abandoned the branch entirely.

Now in my original branch that didn't have any of the experimental work, I'm getting this error.

[BadImageFormatException: Could not load file or assembly 'System.Reactive.Windows.Threading' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]

The error makes sense. What doesn't make sense is why is it even attempting to load the System.Reactive.Windows.Threading assembly in the first place? There is no reference to it in the solution. I even went as far as uninstalling the extensions altogether from the OS.

Here's the binding info.

=== Pre-bind state information ===
LOG: User = IIS APPPOOL\.NET v2.0
LOG: DisplayName = System.Reactive.Windows.Threading
 (Partial)
LOG: Appbase = file:///C:/GitHub/v44/Web/
LOG: Initial PrivatePath = C:\GitHub\v44\Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\GitHub\v44\Web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config
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:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/65a2449d/ebe221c1/System.Reactive.Windows.Threading.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/65a2449d/ebe221c1/System.Reactive.Windows.Threading/System.Reactive.Windows.Threading.DLL.
LOG: Attempting download of new URL file:///C:/GitHub/v44/Web/bin/System.Reactive.Windows.Threading.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.

What is making .NET think it needs to load this assembly?

kareem
  • 753
  • 1
  • 5
  • 10
  • System.Threading is here since .Net 1.1, mate! https://msdn.microsoft.com/en-us/library/system.threading(v=vs.71).aspx – Mihai Caracostea Feb 25 '15 at 20:52
  • "System.Threading.dll was added in .NET 4.0 (though the namespace System.Threading has been around since v1)" http://stackoverflow.com/questions/3405662/why-might-system-threading-dll-be-missing-from-windows-assembly I clarified the question a bit. – kareem Feb 25 '15 at 20:54
  • So until 4.0 those classes in System.Threading were sitting where? Another assembly maybe? – Mihai Caracostea Feb 25 '15 at 20:58
  • 1
    Do you have a .gitignore hiding the fact the DLLs are still sitting in your bin folder? – James World Feb 25 '15 at 21:08
  • Regarding your error, maybe that assembly is a reference for another assembly referenced in your solution. A decompiler should help you see what are the references for an assembly. – Mihai Caracostea Feb 25 '15 at 21:09
  • @mihai The namespace was in mscorlib I believe. What do you mean by decompiler can assist? Is there a tool to trace the dependencies? – kareem Feb 26 '15 at 00:55
  • I use JustDecompile http://www.telerik.com/download/justdecompile from Telerik. I got a licence for the whole lot, but I think this particular package is freeware, anyway. When you decompile any .net assembly, you can also view its dependencies (referenced assemblies). – Mihai Caracostea Feb 26 '15 at 00:58

2 Answers2

0

Found it. So there were genuinely no dependencies to the reactive extension left in my solution. However the old libraries that needed it were still left in my bin folder. Uninstalling the nuget packages doesn't remove them. Once the nuget packages are removed, it appears a Clean doesn't remove them.

Here's what I think happened. So there they are sitting in my bin folder which is ignored by git so switching branches doesn't remove them. .NET sees them in the bin folder and despite nothing needing them tries to load them. I had to completely clean out the workspace of all ignored files as well.

git clean -fxd

Build from there and I'm good to go.

kareem
  • 753
  • 1
  • 5
  • 10
  • important to mention that if you do this, all ["untracked directories in addition to untracked files"](https://git-scm.com/docs/git-clean) and you [can not undo this operation](https://stackoverflow.com/questions/6267180/can-i-undo-a-git-clean-fdx) – r.pedrosa Aug 28 '18 at 10:14
-1

When you say you "installed" Rx what do you mean? Which NuGet package did you use? What Rx references does your project have? Make sure you just use Rx-Main. It sounds like you might have used one of the flavors that includes Rx-Xaml (such as Rx-WPF or Rx-Silverlight). Rx-Xaml loads System.Reactive.Windows.Threading.

http://blogs.msdn.com/b/rxteam/archive/2012/08/15/reactive-extensions-v2-0-has-arrived.aspx describes the different packages and what they include.

Brandon
  • 38,310
  • 8
  • 82
  • 87
  • I originally tried the nuget packages but ended up using their actual installer that put the binaries in the Microsoft.NET extensions folder in the Windows directory. – kareem Feb 26 '15 at 11:44
  • which Rx assemblies are you referencing in your project? – Brandon Feb 26 '15 at 11:48
  • None. Absolutely zero. That's the mind boggling part. I've returned back to the branch prior to doing any of this experimentation. – kareem Feb 26 '15 at 11:50
  • Then most likely it is a dependency of the 3rd party library you are originally trying to use, or possibly a dependency of the "backported" System.Threading – Brandon Feb 26 '15 at 12:12