could not resolve type with token 010000012 - typeloadexception

I'm new in xamarin and have a problem, when i try to run an old Xamarin project in the newest version of vs (2022) this error appear: System.TypeLoadException: 'Could not resolve type with token 01000012 from typeref (expected class 'System.Web.PreApplicationStartMethodAttribute' in assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')'
I set the same version of Xamarin.forms but still see this error. please help

Related

Adding "Uno.Cupertino" or "Uno.Material" to an Uno-Platform project make the project not compile. Even a blank project

After adding "Uno.Cupertino" or "Uno.Material" to any Uno-Platform project even a newly created blank project, the project no longer builds and throws tons of build errors.
Here are some of the common errors:
Error CS0433 The type 'SuspendingEventArgs' exists in both 'Microsoft.Windows.SDK.NET, Version=10.0.19041.24, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'
Error UXAML0001 Unable to find type Windows.UI.Xaml.ElementStub (net6.0-android)
I tried to solve the dependency errors by uninstalling or updating some of the packages to latest version but it makes no difference and it does not compile.

Could not load type 'System.Drawing.FontStyle'

I have a library of classes which work with graphic by system.drowing and web-application on .net core 2. When I try to create object object of class from this lybrary in controller it throws exception
TypeLoadException: Could not load type 'System.Drawing.FontStyle' from assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Please, help to solve problem!

Could not load assembly System.Runtime in Xamarin.Forms UWP Project with .NET Standard library

I'm in the process of setting up a Xamarin.Forms app using .NET Standard for the shared library instead of a PCL. I've followed the instructions for doing so laid out here: https://channel9.msdn.com/Shows/XamarinShow/Snack-Pack-15-Upgrading-to-XamarinForms-to-NET-Standard
This is with a brand new Xamarin.Forms app, created using Visual Studio 2017 with a PCL, which was replaced with a .NET Standard library as described in the video.
The UWP app compiles fine, but throws this exception when I try to start it (on the call to Xamarin.Forms.Forms.Init)
System.IO.FileLoadException: 'Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
I've tried specifically adding the nuget package for System.Runtime, version 4.1.0 to the UWP project, but that doesn't seem to help. It runs fine in Android, but keeps giving me this exception running the UWP project. Can anyone tell me what might be causing this and how I can fix it?
edit:
there is a very similar error in the build log:
Could not resolve this reference. Could not locate the assembly "System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Followed by an extremely long list of places it has checked.
I also found this, which seems like it may be the problem:
2> There was a conflict between "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
2> "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
Does anyone know how I can resolve this conflict?
edit 2:
There's also this in the build logs right after the above, which is even more perplexing, as it seems to indicate the only thing referencing version 4.0.20.0 of System.Runtime is... version 4.3.0 of System.Runtime???
2> References which depend on "System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\Katie.nuget\packages\system.runtime\4.3.0\ref\netcore50\System.Runtime.dll].
2> C:\Users\Katie.nuget\packages\system.runtime\4.3.0\ref\netcore50\System.Runtime.dll
2> Project file item includes which caused reference "C:\Users\Katie.nuget\packages\system.runtime\4.3.0\ref\netcore50\System.Runtime.dll".
2> C:\Users\Katie.nuget\packages\system.runtime\4.3.0\ref\netcore50\System.Runtime.dll

Compilation error at runtime from Microsoft.AspNet.WebApi.HelpPage version 4.0.30506

I am getting the following error when I try to use version 4.0.30506 (unfortunately we are tied to this version of ASP.NEt Web API for now) of the Microsoft.AspNet.WebApi.HelpPage nuget package. I am using Windows 7 and .NET 4.5.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Source Error:
Line 11:
Line 12: // Group APIs by controller
Line 13: ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
Line 14: }
Line 15:
As far as I can see I have all the correct references for this to work. I have tried looking for a System.Runtime assembly as it suggests, but I can't find it on my system. I have added using statements to the top of Index.cshtml, but with no affect.
#using System
#using System.Runtime
Any suggestions of what is causing this error?
check your web.config:
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</compilation>
In my case, this error disappeared when I removed System.Collections.Immutable.dll from Bin directory. This DLL is from NuGet package and is available only for Win8 platforms and I was working with Win7. So it might help you too..
I ran into this error after updating all Nuget packages in an MVC 5, .NET 4.5.1 project, and thanks to Dmitry Lyalin's post discovered the issue related to an updated Nuget package that has become a Portable Class Library.
For those who like to dig, I figured out the culprit by doing the following:
Unload the project
Edit the project
Search for "portable"
Having found Humanizer, I changed it back to pre-PCL version 1.37.7, retested the page, and found that everything worked again.
Knowing the culprit(s), Humanizer in my case, there's two options:
Cap the Humanizer Nuget at version 1.x.y so as not to use the new PCL libraries in v2 via allowedVersions attribute in packages.config:
<package id="Humanizer " version="1.37.7" allowedVersions="[1,2)" />
Do what giammin suggests in his answer and add the System.Runtime assembly under system.web in web.config:
<system.web><compilation ...><assemblies><add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /></assemblies></compilation></system.web>

ThinkTecture.IdentityModel "The type 'System.IdentityModel.Tokens.SecurityToken' is defined in an assembly that is not referenced

I start using ThinkTecture.IdentityModel in my project and I am facing a serious issue. Please help me on the same.
Error 1 "The type 'System.IdentityModel.Tokens.SecurityToken' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Try manually adding the System.IdentityModel dll reference from the assemblies. This is what worked for me.
-Right click project, add reference
-Assemblies, Framework, System.IdentityModel v4.0.0.0

Resources