When trying to build my Android project in Xamarin Studio, I keep getting errors like these:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error: Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Mono.Android.Support.v4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.
Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Mono.Android.Support.v4.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() (Akva20150407)
-
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2,2):
Error: Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, PublicKeyToken='.
Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.v4.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() (Akva20150407)
-
C:\progge\Apper\Akva20150407\Akva20150407\Act_MainGUI.cs(29,29):
Error CS0433: The type 'Android.Support.V4.App.FragmentActivity' exists in both
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\Mono.Android.Support.v4.dll' and
'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.0\Xamarin.Android.Support.v4.dll'
(CS0433) (Akva20150407)
I must add Xamarin.Android.Support.v4 to the MonoAndroid folder, or it will complain that it can't find it.
I must add Mono.Android.Support.v4 to the MonoAndroid folder, or it will complain that it can't find it.
If I add both, it will complain that FragmentActivity can be found in both packages.
The packages were installed via NuGet.
It looks very much self-contradicting.... What on Earth am I supposed to do to get this working??
Upgrade your Xamarin Studio
This bug was fixed in Xamarin Studio: 5.7.0.436.
See bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=24276
Related
My solution and projects are successfully built. When I run the main Web project, I am getting the error System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Screenshot attached:
Stacktrace:
at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityKeyProvider..ctor(String issuer, IEnumerable`1 keys) in /_/src/Microsoft.Owin.Security.Jwt/SymmetricKeyIssuerSecurityKeyProvider.cs:line 50
at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityKeyProvider..ctor(String issuer, Byte[] key) in /_/src/Microsoft.Owin.Security.Jwt/SymmetricKeyIssuerSecurityKeyProvider.cs:line 24
at A.B.Azure.AppBuilderExtensions.ConfigureOAuth(IAppBuilder app) in ...\AppBuilderExtensions.cs:line 32
at A.B.Api.Startup.Configuration(IAppBuilder app) in ...\Startup.cs:line 67
How did I got here?:
I updated all the Nuget packages in all my projects, especially Microsoft.Owin.Security.Jwt and Microsoft.IdentityModel.Tokens, to their latest versions - 4.2.2 and 6.22.0, respectively!
I updated all the assemblyBinding and packages.config, but can't fix it!
What am I missing here?
I have some libraries built on C# .NET Core 3.1.
When I execute the command
dotnet build "core\core.csproj"
I get the following error
C:\Users\christos.nuget\packages\visual-stylecop.msbuild\4.7.59\build\Visual-StyleCop.MSBuild.Targets(107,5): error MSB4062: The "StyleCopTask" task could not be loaded from the
assembly
C:\Users\christos.nuget\packages\visual-stylecop.msbuild\4.7.59\build..\tools\StyleCop.dll.
Could not load file or assembly 'System.Windows.Forms,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The system cannot find the file specified. Confirm that the
declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements Microsoft.Build.Framework.ITask.
But when I use msbuild
& 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' "core\core.csproj"
it finishes without problems.
Any idea why?
thanks in advance for any help
Using Microsoft Visual Studio 2022 to build a C# Web API project with .NET 6 Framework, the project builds fine on one machine. I cloned the same source code repository into a different machine, but when building in the new machine I get the following error:
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.ComputeManifestHash()
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.Create(String source, String basePath, String mode, String manifestType, ReferencedProjectConfiguration[] referencedProjectConfigurations, DiscoveryPattern[] discoveryPatterns, StaticWebAsset[] assets)
at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
ResultsMonitor.API C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 411
Severity Code Description Project File Line Suppression State
Error FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.ComputeManifestHash()
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.Create(String source, String basePath, String mode, String manifestType, ReferencedProjectConfiguration[] referencedProjectConfigurations, DiscoveryPattern[] discoveryPatterns, StaticWebAsset[] assets)
at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
ResultsMonitor.API C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 411
Furthermore, on the new machine:
If I use JetBrains Rider 2022.1.1 to open the same project, it just builds and runs fine.
If I do a "dotnet build" from the terminal, build also succeeds.
What is wrong with Visual Studio 2022? I even uninstalled and reinstalled Visual Studio 2022 and the .NET 6 SDK for Visual Studio
I'm working in a github cloned Xamarin project. When I open up the project it displays the following error:
Severity Code Description Project File Line Suppression State
Error Could not load file or assembly 'System.Collections.Immutable,
Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of
its dependencies. The located assembly's manifest definition does not match
the assembly reference. (Exception from HRESULT: 0x80131040) ProjectName
C:\Users\USER\.nuget\packages\refit\4.6.30\build\netstandard1.4\refit.targets
29
I've tried cleaning the project, deleting the bin/obj folders and I've cleared my nuget packages and restored. All of these solutions didn't work and when trying to rebuild the project it displays another error:
Severity Code Description Project File Line Suppression State
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'ProjectName,
Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist
in the Mono for Android profile?
File name: 'ProjectName.dll'
at
Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.
<ExecuteInstantiatedTask>d__26.MoveNext() ProjectName.Android
I'm using Visual Studio Community 2017 version 15.8.8 and Xamarin.Forms
2.5.0.280555
The project that I'm working on works on other pc's from co-workers so I think it has to do with my VS installation. I tried to reinstall VS but this resulted in the same errors.
So my solution compiles but when I run it I get an error in the class library that is running .NET 4.6.1.
System.TypeLoadException: 'Could not load type 'System.Data.Common.DbProviderFactories' from assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Any suggestions?
EDIT:
Complete error:
$exception {System.TypeLoadException: Could not load type 'System.Data.Common.DbProviderFactories' from assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func3 handleFailedLookup)
at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetServices(Type type, Object key)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()
at System.Linq.Enumerable.ConcatIterator1.MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext()
at System.Linq.Enumerable.ConcatIterator1.MoveNext()
at System.Linq.Enumerable.<OfTypeIterator>d__321.MoveNext()
at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at System.Data.Entity.Infrastructure.DependencyResolution.InternalConfiguration.Lock()
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.<.ctor>b__1()
at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy1.CreateValue()
at System.Data.Entity.Infrastructure.DependencyResolution.DbConfigurationManager.GetConfiguration()
at System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection, DbCompiledModel model)
at X.Y.ConfigurationModule.ConfigurationContainer..ctor(String nameOrConnectionString)} System.TypeLoadException
You see this type of errors when the assembly your are using is different from the reference assembly.
Example
In this condition you see this error because first one using version 3 and other using 2
Please do these check
1:Open references right click on System.Data.Common.DbProviderFactories assembly
and check its version
2:Now open you package config or app config file and check the version of that assembly there.
Solution
If versions conflict please install the library from
https://www.nuget.org/packages/System.Data.Common/
Then go to bin folder delete the 'System.Data.Common.DbProviderFactories' dll also delete it from references from your project then click add references go to packages folder because the latest library you downloaded goes in this folder so just add reference.
Now right click on this assembly and copy version name and paste that version in your appconfig or packages config file.