System.IO.Compression Reference issue - c#

I am working on .NET framework 4.6 Web API application. My app is working on my machine and I was able to build it in my local but when I push it to our Azure Dev OPS CI, I got this build error.
Error CS0433: The type 'ZipArchive' exists in both 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
: Error CS0433: The type 'ZipArchiveMode' exists in both 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and 'System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Process 'msbuild.exe' exited with code '1'.

Related

Could not load type 'System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider' from assembly

I am getting this error in .net core installed annotation 4.0 version But It is Not Working How can I Solve This error.
Could not load type
'System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
thank you.

The type 'MediaTypeHeaderValue' exists in both 'System.Net.Http"

please help,
I am getting following error when I am trying to access API endpoint:
Compiler Error Message: CS0433: The type 'MediaTypeHeaderValue' exists in both 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Net.Http, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

MySQLBackup in c#

How to solve this error ?
Error 1 Assembly 'MySqlBackup, Version=2.0.9.2, Culture=neutral,
PublicKeyToken=null' uses 'MySql.Data, Version=6.9.9.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d' which has a higher version than referenced
assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d' c:\Users\Mohammed Abdullah\Desktop\MySqlBackup.dll mobile_shop
Add reference to
MySql.Data
in you cs project

Ambiguous Reference System.Net.Http.Formatting

I am using VS2015 .Trying to use System.Net.Http.Formatting gives me an error saying:
Severity Code Description Project File Line
Error CS0433 The type 'MultipartMemoryStreamProvider' exists in both 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' aaAPIs C:\Working\Angular\aa\Controllers\Product\ImagesController.cs 22
How can I solve this?

Build with PostSharp Toolkit fails on 4.5.1 but works with 4.5

I have preserved a NuGet package of PostSharp.Toolkit.Threading, version 2.1.1.12, because I can't upgrade to version 3.x. Any project compiles fine, as long as I stay on .Net 4 or 4.5, but as soon as I change to 4.5.1 or 4.5.2, I get this error:
Error 3 error: Unhandled exception (2.1.7.35, 32 bit, CLR 2.0, Release): Cannot load assembly T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll.
============ PostSharp Assembly Loading Log ===================
LOG: NativeDotNetPlatform.LoadAssemblyFromFile: T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll.
LOG: Assembly identity returned by the host: postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil.
LOG: Assembly 'postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil' is not yet loaded in the AppDomain.
LOG: Invoking Assembly.Load({postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil})
LOG: (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil".
LOG: Finding the assembly with binding identity 'postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil'.
LOG: Location found from cache: 'T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll'.
LOG: (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": assembly found in search path.
LOG: (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": located in "T:\WindowsFormsApplication4\packages\PostSharp.Toolkit.Threading.2.1.1.12\tools\PostSharp.Toolkit.Threading.Weaver.dll".
LOG: (ClrHost) ProvideAssembly: "postsharp.toolkit.threading.weaver, version=0.0.0.0, culture=neutral, publickeytoken=null, processorarchitecture=msil": returned successfully.
LOG: AssemblyLoadException: Could not load file or assembly 'postsharp.toolkit.threading.weaver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
LOG: Loaded: 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll'.
LOG: Loaded: 'PostSharp.Hosting, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Hosting.dll'.
LOG: Loaded: 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System.Core\3.5.0.0__b77a5c561934e089\System.Core.dll'.
LOG: Loaded: 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll'.
LOG: Loaded: 'PostSharp.Sdk, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Sdk.dll'.
LOG: Loaded: 'PostSharp.Settings, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Settings.dll'.
LOG: Loaded: 'PostSharp, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.dll'.
LOG: Loaded: 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' from 'C:\Windows\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll'.
LOG: Loaded: 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'.
LOG: Loaded: 'PostSharp.Pipe, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Pipe.dll'.
LOG: Loaded: 'PostSharp.Sdk.XmlSerializers, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' from 'T:\WindowsFormsApplication4\packages\PostSharp.2.1.7.35\tools\Release\PostSharp.Sdk.XmlSerializers.dll'.
=============================================================== See below for details. T:\WindowsFormsApplication4\WindowsFormsApplication4\POSTSHARP WindowsFormsApplication4
I can't figure out why this is happeneing. Any P# gurus out there?
The log shows that PostSharp hosting CLR version is 2.0. While loading the threading weaver assembly, CLR also attempts to load some dependency that requires CLR 4.0. This is when you get an exception.
PostSharp 2.x can recognize target framework 4.5 and automatically choose hosting CLR 4.0, however the newer framework version 4.5.1 is not recognized and CLR 2.0 is used by default.
You can override the hosting CLR by setting the MSBuild property PostSharpTargetFrameworkVersion to 4.0.

Categories