So I create a Forms solution, in my PCL project I add the NuGet Microsoft.WindowsAzure.Mobile.
When I run my Android project (which of course references the PCL project), I get:
[MonoDroid] UNHANDLED EXCEPTION:
System.Reflection.TargetInvocationException: Exception has been
thrown by the target of an invocation.
---> System.InvalidOperationException:
A Microsoft Azure Mobile Services assembly for the current platform was not found.
Ensure that the current project references both Microsoft.WindowsAzure.Mobile and the following platform-specific
assembly: Microsoft.WindowsAzure.Mobile.Ext.
Ok, fine, I add the Microsoft.WindowsAzure.Ext (by manually Edit References->Browse to the ..packages..Microsoft.WindowsAzure.Mobile.Ext assembly and add it) to my Android project, but then I get:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.AndroidAccountStore/SecretAccount, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.AndroidAccountStore/SecretAccount,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.FormAuthenticatorActivity, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.FormAuthenticatorActivity,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.FormAuthenticatorActivity/State, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.FormAuthenticatorActivity/State,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.WebAuthenticatorActivity, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.WebAuthenticatorActivity,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.WebAuthenticatorActivity/State, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.WebAuthenticatorActivity/State,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets:
Error: Duplicate managed type found! Mappings between managed types
and Java types must be unique. First Type:
'Xamarin.Auth.WebAuthenticatorActivity/Client, Xamarin.Auth.Android,
Version=1.2.2.0, Culture=neutral, PublicKeyToken=null'; Second Type:
'Xamarin.Auth.WebAuthenticatorActivity/Client,
Microsoft.WindowsAzure.Mobile.Ext, Version=1.2.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' (MyApp.Android)
Seems to be some conflict with Xamarin.Auth?
How do I solve this?
I have manage to find a workaround. Create a Portable Class Library in which you add the nugget version of mobile services. In this way you can make a wrapper over the existing mobile services from the pcl. This clearly works and it the best solution till the bug is fixed. If you have any questions please feel free to ask.
This error is resolved as of version 1.2.5 of the Mobile Services SDK.
Related
I am facing a problem i need some help.Problem is that i publish a web application in Godaddy server it is giving internal server error while it is working fine in visual studio and when i go in details of the error it giving fallowing message
Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
Prasadseed.WebApiApplication.Application_Start() +0
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +10103347
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +123
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +181
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +228
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +314
[HttpException (0x80004005): Could not load file or assembly 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10083568
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +263
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3928.0
I am trying to start developing with Xamarin. I am using follwing Visual Studio version:
Microsoft Visual Studio Enterprise 2017 Version 15.5.2 (VisualStudio.15.Release/15.5.2+27130.2010)
Microsoft .NET Framework Version 4.7.02556
I create a new Xamarin project and get the errors below (without adding any code). I tried reinstalling Xamarin with no luck. Any ideas on how to fix this?
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 12 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 12 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 12 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 13 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 15 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 17 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 18 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 20 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 22 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 23 Active
Error CS0012 The type 'AppCompatActivity' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 23 Active
Error NU1202 Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)
Error NU1202 Package Xamarin.Android.Support.v7.CardView 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.CardView 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)
Error NU1202 Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v7.AppCompat 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)
Error NU1202 Package Xamarin.Android.Support.v4 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.v4 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)
Error NU1202 Package Xamarin.Android.Support.Design 25.4.0.2 is not compatible with monoandroid60 (MonoAndroid,Version=v6.0). Package Xamarin.Android.Support.Design 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)
Error CS1503 Argument 1: cannot convert from 'App4.Droid.MainActivity' to 'Android.Content.Context' App4.Android C:\Users\thomaseg\Documents\Visual Studio 2017\Projects\App4\App4\App4.Android\MainActivity.cs 22 Active
Did you update all your packages? I got this error a while ago and updating them fixed it for me (Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution -> Updates, then Update all)
I saw multiples post/question about it on StackOverflow but about ASP.NET
I am getting the following:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Web.Mvc.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/5749/9cfa7836/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:229
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5749/9cfa7836/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:179
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <998d78d5ee6d46b491b77aff8eeaf856>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x001c7] in <998d78d5ee6d46b491b77aff8eeaf856>:0 (NightLine.Droid)
Now the interesting point is that my project isn't an ASP.NET project att all x) So first, what the hell?
I did this video: https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-15-Upgrading-to-XamarinForms-to-NET-Standard
I upgrated the .NET Standard project to 2.0. My Android target is 8.0 and the compiler as well. I tried to upgrade all of my Xamarin.Android.* packages but no success...
Any idea?
Thanks
I am signing both pcl and uwp and getting error:
System.IO.FileLoadException: Could not load file or assembly 'Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Indeed the assembly Xamarin.Forms.Xaml is not signed (Strong name = false)
I have a web app that uses MEF, Webapi and OData.
For MEF I created a helper class that loads the catalog on demand (at first access)
The following is MEF integration code.
Public Shared ReadOnly Property Catalog As AggregateCatalog
Get
If _catalog Is Nothing Then
Dim catFolder = "."
Dim path = AppDomain.CurrentDomain.BaseDirectory.ToLower
_catalog = new AggregateCatalog()
Dim di = New DirectoryInfo(path)
Dim dlls = di.GetFileSystemInfos("MyApp.*.dll")
_catalog = New AggregateCatalog()
For Each dll In dlls
Try
Dim ac = New AssemblyCatalog(Assembly.LoadFile(dll.FullName))
Dim parts = ac.Parts.ToArray() 'throws ReflectionTypeLoadException
_catalog.Catalogs.Add(ac)
Catch ex As ReflectionTypeLoadException
Log.Instance.Error("Error when Trying to load {0}", dll.FullName)
Log.Instance.Error(ex)
For Each iex In ex.LoaderExceptions
Log.Instance.Error(iex)
Next
End Try
Next
End If
Return _catalog
End Get
End Property
One of my projects (the actual web app project) uses the following nuget packages (among others):
WebApi 5.2.3
WebApi.OData 5.7.0
My problem is when MEF class tries to load this assembly (the one that uses OData and WebApi, it thrown a runtime error, which is logged below.
The problem occurs ONLY in deployment, on production machine. In development all works ok.
As you can see in the error below, it seems that, even if the project references System.Web.Http version 5.2.3.0, at runtime System.Web.Http.Odata assembly is trying to load System.Web.Http version 5.2.2.0 (!?!?!?)
In my project, the reference is set to correct dll (version 5.2.3.0), the dll is set with Copy Local=True, and in web.config I have
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
I don't have any class needed to be composed by MEF in this project (assembly), so I could simply exclude it from being load by MEF, but this error is puzzling me, and I would like to find a solution, in case I encounter similar problem in other assemblies.
Here is the error I get
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|Error when Trying to load m:\web\www.mypermitnow.org\web_1\bg-processor\MyPermitNow.Jurisdiction.dll
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetEnumerator()
at System.Linq.EnumerableQuery`1.GetEnumerator()
at System.Linq.EnumerableQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at MyPermitNow.MEFHelper.get_Catalog()
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog()
at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetEnumerator()
at System.Linq.EnumerableQuery`1.GetEnumerator()
at System.Linq.EnumerableQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at MyPermitNow.MEFHelper.get_Catalog()
2015-11-04 07:17:02.7758|ERROR|MyPermitNow.Log|System.IO.FileLoadException: Could not load file or assembly 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///M:/web/www.mypermitnow.org/web_1/bg-processor/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Web.Http.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///M:/web/www.mypermitnow.org/web_1/bg-processor/System.Web.Http.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
There could be a lot of things that could cause this. Some things to check:
Is there an old version of the DLL on the server having problems? It is possible the CSPROJ now has Private=true for the assembly when it didn't use to, then that library is included in the main applicate/site project. So the new one isn't getting copied, but the old one is sitting there but in a more direct spot so it is loading first.
Any app/web.config transforms going on that could be replacing the assembly binding XML?
If it's not in the direct application folders, what's in the GAC?
Turn on the Fusion assembly loading logging