Project trying to load system.web that actually no need (Xamarin) - c#

I'm making an xamarin android project with asp.net web api. I put api project and android project in same solution. Android project get data from the api through data service. But when I added zxing NuGet package and I build the project this error came. Do the project really need this assembly? I guess not. But suddenly the project trying to load this assembly.
So, I got this error:
Severity Code Description Project File Line Suppression State Error
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'System.Web, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono
for Android profile? File name: 'System.Web.dll' at
Java.Interop.Tools.Cecil.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()
This error make the project can't be build, debug and run.
At first android project didn't need this reference.
I did add system.web references to my project, but after I added the reference this message warning showed up:
There was a mismatch between the processor architecture of the project
being built "MSIL" and the processor architecture of the reference
"System.Web", "AMD64". This mismatch may cause runtime failures.
Please consider changing the targeted processor architecture of your
project through the Configuration Manager so as to align the processor
architectures between your project and references, or take a
dependency on references with a processor architecture that matches
the targeted processor architecture of your project. ShopDiaryApp
At first project no need this reference. but now why they trying to load one? they make this warning uncomfortable and afraid it will cause problem at the end.
Any ideas to remove this warning? Thanks in advance.

Related

Setting TargetFramework=net472 Still gives error "Could not load file or assembly 'netstandard, Version=2.1.0.0"

I have multi project solution that includes an ASP.NET Web API project and all projects were originally built in >NET Framework 4.7.2. One of the class library projects in the solution I changed to a multi target:
<TargetFrameworks>net472;netstandard2.1</TargetFrameworks>
I worked through everything (specifying different nuget packages for target frameworks and #if NET472_OR_GREATER statements throughout code) and was able to get it to build. With the if statements and target nuget packages, the project is exactly the same for net472 (differences only for netstandard) as it was before the multi target.
I have changed the project references in the .csproj file for all the other projects that reference this project like this:
<ProjectReference Include="..\MyProject\MyProject.csproj">
<SetTargetFramework>TargetFramework=net472</SetTargetFramework>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
Yet, when I run the Web API project (which builds successfully), I get the error:
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
What am I doing wrong? The Web API project should not need .NET Standard 2.1, right?

.NETCore 3.1 - Error MC1000 Unknown build error, 'Could not find assembly 'System.Web, Version=4.0.0.0

Using Visual Studio 16.6, migrating WPF app to target .netcore3.1(.300). Cannot compile with error below:
Error MC1000 Unknown build error, 'Could not find assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Either explicitly load this assembly using a method such as LoadFromAssemblyPath() or use a MetadataAssemblyResolver that returns a valid assembly.' MyApp C:\Program Files\dotnet\sdk\3.1.300\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets 225
I don't seem to have any need or reference for System.Web
I see similar things here but am on current versions:
https://github.com/dotnet/wpf/issues/2648
Any ideas?
There seemed to be an issue with the structure of the project file. I don't reference System.Web but a third party DevExpress component does.
When you target .netcoreapp31 AND net472, the Nuget packages do not seem to get pointed to the target frameworks correctly. The project file needed to be manually restructured to point them to the correct frameworks.
Details here:
Issue on github dotnet/wpf

.Net Core deps file modification not reflected

I have a .NET Core project with many libraries as dependencies.
I wanted to change code in one of the library (a dll dependency) and wanted to run the project using the said new dll.
I changed the file version of the dll in the deps.json file but when i run the project using dotnet project.dll I see this exception thrown:
Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'CuPletEngine, Version=16.0.229.1809, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
I made the change to deps.json file in order to force the application to to look for a different dll version.
Why would it still look for older version?
Please help.

ASP.NET web site builds locally, but throws MSB3268 on the build server

I added a project to my web site solution. Everything built fine locally and on the build server.
I added a line in web code to call a method in the new project. Everything built and worked fine locally, but it broke the build on the build server.
I got a pile of errors going something like this:
warning MSB3268: The primary reference "C:...\ProjectName.dll" could not be resolved because it has an indirect dependency on the framework assembly "Assembly.Name (e.g. System.Runtime)", 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 "C:...\ProjectName.dll" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
After all the warnings, the build failed with an error indicating the namespace ProjectName could not be found. Makes sense considering the project's dependencies couldn't be resolved.
At first I wondered if there was an issue with targeting the wrong framework. But there was a mix of 4.0 and 4.5 projects referenced by the 4.5 website. This was the first one that had failed.
The only difference between this and the other projects was that it referenced third-party DLLs. So apparently their dependencies are the ones that couldn't be resolved.
This post held the key: http://devsilos.blogspot.com/2014/10/msb3268-while-targeting-aspnet-web-site.html
The author suggests:
aspnet_compiler for some reason does not take into account the .dll-s that reside under the Facade directory of 4.5 assemblies (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades).
It looks only under
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5
My extrapolation on that idea is that maybe the compiler doesn't take into account DDLs in the Facades directory if they're referenced by a third-party DLL rather than directly from your project.
The solution, as suggested by the author, was to find the DLLs matching assemblies mentioned in the MSB3268 warnings and copy them from Facades to its parent directory.
I think my problem/solution differed from the blog's in that it had nothing to do with the .NET Framework version targeted. It had only to do with whether the build server's compiler looked in the right places to resolve third-party DLLs' dependencies.
The problem caused about ten hours of frustration. I hope this helps someone else avoid that!

Xamarin visual studio filenotfoundException Windows.winmd

I'm creating a Portable Xamarin.Forms project, and I just added some pages I had on my shared project fixing errors.
After the edits, the project doesn't compile with the error
Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly "Windows.winmd, Version=, Culture=neutral, PublicKeyToken='. Pheraps it doesn't exist in the Mono for Android profile?
Project: myproject.Droid
Plus others 4670 errors like this:
file .winmd "Windows.winmd" contains type 'Windows.Storage.Streams.IDataWriter'. Windows namespace usage is reserved.
Project: myproject.WinPhone
Any error has a different type and they all refers to the WinPhone project.
I tryed checking in the Droid references for the Mono.Android but this is the scenario:
(the selected one was thicked, i deselected it for testing, but still same error)
What can I do?
Thanks all

Categories

Resources