Reactive (Rx) build issue with .Net 4.5 and NuGet - visual-studio-2012

This has caused me quite the embaressment today. While I was demoing Rx 2.x features and capabilities, I tried to build a NuGet enabled project which I copied from another computer.
Everything was downloaded correctly, the references are there! but I can't compile.
These two below assemblies are causing the issue. I am wondering if anyone has faced this issue with restroing Rx assemblies into a .Net 4.5 project.
System.Reactive.Windows.Threading
Warning 11 The primary reference "System.Reactive.Windows.Threading,
Version=2.1.30214.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" could not be resolved because it has an
indirect dependency on the framework assembly "System.Threading.Tasks,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
which could not be resolved in the currently targeted framework.
".NETFramework,Version=v4.5". To resolve this problem, either remove
the reference "System.Reactive.Windows.Threading, Version=2.1.30214.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" or retarget your application to a
framework version which contains "System.Threading.Tasks,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
And System.Reactive.PlatformServices
Warning 26 The primary reference "System.Reactive.PlatformServices"
could not be resolved because it has an indirect dependency on the
framework assembly "System.Runtime.Extensions, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be
resolved in the currently targeted framework.
".NETFramework,Version=v4.5". To resolve this problem, either remove
the reference "System.Reactive.PlatformServices" or retarget your
application to a framework version which contains
"System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a".
Couldn't compile:
Error 73 The type or namespace name 'IScheduler' could not be found
(are you missing a using directive or an assembly
reference?)
Error 74 The type or namespace name 'CompositeDisposable' could not be
found (are you missing a using directive or an assembly
reference?)

My psychic debugger says this has something to do with either mixing references to .NET 4.0 and .NET 4.5 Rx DLLs in a project, or Microsoft.Bcl.Async.

Related

How to figure out the main issue in a Nuget Package

I recently updated my packages and I started to get this weird warning in a few projects. I'm unable to resolve it:
Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that could not be resolved.
There was a conflict between "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll].
C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll".
C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
References which depend on "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll".
C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
C:\Users\0000\.nuget\packages\system.collections.immutable\5.0.0\lib\net461\System.Collections.Immutable.dll
C:\Users\0000\.nuget\packages\nito.disposables\2.2.1\lib\net461\Nito.Disposables.dll
C:\Users\0000\.nuget\packages\nito.asyncex.context\5.1.2\lib\net461\Nito.AsyncEx.Context.dll
C:\Users\0000\.nuget\packages\nito.asyncex.coordination\5.1.2\lib\net461\Nito.AsyncEx.Coordination.dll
C:\Users\0000\.nuget\packages\nito.asyncex.oop\5.1.2\lib\net461\Nito.AsyncEx.Oop.dll
C:\Users\0000\.nuget\packages\nito.asyncex.tasks\5.1.2\lib\net461\Nito.AsyncEx.Tasks.dll
C:\Users\0000\.nuget\packages\nito.asyncex.interop.waithandles\5.1.2\lib\net461\Nito.AsyncEx.Interop.WaitHandles.dll
C:\Users\0000\.nuget\packages\nito.cancellation\1.1.2\lib\net461\Nito.Cancellation.dll
C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll".
C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
C:\Users\0000\.nuget\packages\utf8json\1.3.7\lib\net47\Utf8Json.dll
C:\Users\0000\.nuget\packages\easy.logger.extensions\1.5.0\lib\net45\Easy.Logger.Extensions.dll Focus.Tests.LogicTester
How do I decipher what is the actual issue here? Is there a package that internally depend on a specific version of a DLL but that DLL is also addedd directly with a newer version?
In short, you have dependencies on two different versions of the same DLL. Breakdown below, but TL;DR, you should be able to resolve this by updating your PackageReference to System.Runtime.CompilerServices.Unsafe to version 6.0.0.
If you don't call into it directly, consider removing the PackageReference, as it should be added transitively via the other references listed below.
If you don't have a PackagerReference to this package, adding one (using version 6.0.0) would make that the primary reference, thereby again aligning everything at the same version.
Error message breakdown:
Found conflicts between different versions of "System.Runtime.CompilerServices.Unsafe" that could not be resolved.
There was a conflict between "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
The compiler picked one based on some measure of how directly you referenced it (as opposed to one of your dependencies referencing it):
"System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
The 5.0 version is referenced by:
References which depend on "System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll].
C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
The item in the project that creates this runtime dependency on the 5.0 file seems to be itself, i.e. you reference it directly:
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll".
C:\Users\0000\.nuget\packages\system.runtime.compilerservices.unsafe\5.0.0\ref\net461\System.Runtime.CompilerServices.Unsafe.dll
The 6.0 version is referenced by these dependencies:
References which depend on "System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
...
C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
...
These are indirectly referenced via other packages:
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll".
C:\Users\0000\.nuget\packages\system.memory\4.5.4\lib\net461\System.Memory.dll
C:\Users\0000\.nuget\packages\system.collections.immutable\5.0.0\lib\net461\System.Collections.Immutable.dll
C:\Users\0000\.nuget\packages\nito.disposables\2.2.1\lib\net461\Nito.Disposables.dll
C:\Users\0000\.nuget\packages\nito.asyncex.context\5.1.2\lib\net461\Nito.AsyncEx.Context.dll
C:\Users\0000\.nuget\packages\nito.asyncex.coordination\5.1.2\lib\net461\Nito.AsyncEx.Coordination.dll
C:\Users\0000\.nuget\packages\nito.asyncex.oop\5.1.2\lib\net461\Nito.AsyncEx.Oop.dll
C:\Users\0000\.nuget\packages\nito.asyncex.tasks\5.1.2\lib\net461\Nito.AsyncEx.Tasks.dll
C:\Users\0000\.nuget\packages\nito.asyncex.interop.waithandles\5.1.2\lib\net461\Nito.AsyncEx.Interop.WaitHandles.dll
C:\Users\0000\.nuget\packages\nito.cancellation\1.1.2\lib\net461\Nito.Cancellation.dll
...
Project file item includes which caused reference "C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll".
C:\Users\0000\.nuget\packages\system.threading.tasks.extensions\4.6.0-preview.18571.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll
C:\Users\0000\.nuget\packages\utf8json\1.3.7\lib\net47\Utf8Json.dll
C:\Users\0000\.nuget\packages\easy.logger.extensions\1.5.0\lib\net45\Easy.Logger.Extensions.dll Focus.Tests.LogicTester

issues after updating to Xamarin Studio

Could not register the assembly
Error messages that I am getting:
'MonoTouch.Dialog-1': MonoTouch.MonoTouchException: Cannot register two managed types('MonoTouch.Dialog.BaseBooleanImageElement+TextWithImageCellView, MonoTouch.Dialog-1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
and
'MonoTouch.Dialog.BaseBooleanImageElement+TextWithImageCellView, xxxxx1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null') with the same native name('MonoTouch_Dialog_BaseBooleanImageElement_TextWithImageCellView').
tried with mtouch arguments --registrar:legacy, not able fix the issue.
You've included both MonoTouch.Dialog-1.dll and MonoTouch.Dialog.dll in your app. Choose one.

Could not compute a complete dependency map for the project

i would like to get rid of this message so build time dramatically decreases (it builds and runs ok).
This warning appears in mtouch.
warning MT3006: Could not compute a complete dependency map for the
project. This will result in slower build times because Xamarin.iOS
can't properly detect what needs to be rebuilt (and what does not need
to be rebuilt). Please review previous warnings for more details.
Test solution: helloworld mvvmcross solution with ios project and pcl (wp8+monotouch+net45+android) + Microsoft HTTP PCL package in pcl only + an async call to HttpClient.GetStringAsync in the pcl.
Full log:
warning MT3005: The dependency 'System.Windows, Version=2.0.5.0,
Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly
'Cirrious.CrossCore, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=e16445fd9b451819' was not found. Please review the
project's references.
warning MT3005: The dependency 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly
'Cirrious.MvvmCross, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=e16445fd9b451819' was not found. Please review the
project's references.
warning MT3005: The dependency 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly
'Cirrious.MvvmCross.Binding, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' was not found. Please review the project's
references.
warning MT3005: The dependency 'System.Net.Primitives, Version=3.9.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of
the assembly 'Com.Catenum.Intouch.Business, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' was not found. Please review the
project's references.
warning MT3005: The dependency 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of the assembly
'Com.Catenum.Intouch.Business, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' was not found. Please review the project's
references.
warning MT3005: The dependency 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of
the assembly 'Com.Catenum.Intouch.Business, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' was not found. Please review the
project's references.
warning MT3006: Could not compute a complete dependency map for the project. This will result in slower build times because
Xamarin.iOS can't properly detect what needs to be rebuilt (and what
does not need to be rebuilt). Please review previous warnings for more
details.
You must make sure that all the assemblies only reference BCL assemblies that Xamarin.iOS ships.
For example:
warning MT3005: The dependency 'System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of the assembly 'Com.Catenum.Intouch.Business, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' was not found. Please review the project's references.
Xamarin.iOS does not have a System.Net.Http v1.5.0.0, it has v2.0.5.0 instead (all the Xamarin.iOS base class libraries have version v2.0.5.0, except monotouch.dll itself). The solution is to recompile Com.Catenum.Intouch.Business as a Xamarin.iOS class library (this typically involves creating a new Xamarin.iOS class library project, and link the source files in), which will ensure it contains the correct reference to System.Net.Http.dll.
Note that in Xamarin.iOS 7.0.4 there is a (harmless) bug which causes spurious MT3005/3006 warnings in some cases. This is probably the case for the first warning:
warning MT3005: The dependency 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly 'Cirrious.CrossCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e16445fd9b451819' was not found. Please review the project's references.
since Xamarin.iOS does contain a System.Windows assembly with that version.

The dependency ''mscorlib, Version=2.0.0.0,...' was not found

i get the following error by compiling my project:
warning MT3005: The dependency 'mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' of the assembly
'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral,
PublicKeyToken=null' was not found. Please review the project's
references.
warning MT3005: The dependency 'System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' of the assembly
'ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral,
PublicKeyToken=null' was not found. Please review the project's
references.
warning MT3006: Could not compute a complete dependency map for the
project. This will result in slower build times because Xamarin.iOS
can't properly detect what needs to be rebuilt (and what does not need
to be rebuilt). Please review previous warnings for more details.
I've found out that the System dependency of my project uses the version 2.0.5.0 and the ZipSharp uses 2.0.0.0
What should I do?
To fix the warnings you need to get (or build from sources) a version of ZipSharp that is compiled against the BCL (mscorlib.dll, System.dll) that is shipped with Xamarin.iOS (i.e. 2.0.5.0).
Note that those are warnings, not errors, so it might work.

Failed to resolve "Microsoft.Win32.RegistryKey" reference from "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" (MT2002)

When trying to debug on my iPhone I get the error:
Error MT2002: Failed to resolve "Microsoft.Win32.RegistryKey" reference from "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" (MT2002)
What does this mean and how do I fix it?
The issue you are seeing is a result of using the type Microsoft.Win32.RegistryKey in your project or any third party libraries, this likely not available in MonoTouch
I would take a look at the library you have developed and double check everything is ok.

Resources