Assembly binding redirect in .NET Core - asp.net-core

How do I do assembly binding redirect in .NET Core?
I found this question asked a few time with no solutions offered. The situation is trivial. I have a package refering to assembly A in version 10. I want to use assembly A in version 12. In a standard .NET it works perfectly with this:
<dependentAssembly>
<assemblyIdentity name="Microsoft.AnalysisServices.AdomdClient" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-15.1.52.23" newVersion="12.0.0.0" />
</dependentAssembly>

With help of Rena, adding
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
to the project file helped. The .config file got autogenerated with the correct binding redirect.

Related

how to change web.config when upgrading to Microsoft.WindowsAzure.StorageClient 4.3

I'd like to know how to change web.config when upgrading to Microsoft.WindowsAzure.StorageClient 4.3. Current web.config is like
<assemblyIdentity name="Microsoft.WindowsAzure.StorageClient" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.7.0.0" newVersion="1.7.0.0" />
You can directly delete it. This configuration is used for binding "Microsoft.WindowsAzure.StorageClient" reference which is older than 1.7.0.0 to the assembly whose version is 1.7.0.0. For example, originally the project references Microsoft.WindowsAzure.StorageClient 1.5.0.0 in compile time, after this part is added to web.config, it can leverage Microsoft.WindowsAzure.StorageClient 1.7.0.0 instead of 1.5.0.0 in run time, as long as the assembly is backward-compatible.
Because you have replaced "Microsoft.WindowsAzure.StorageClient.dll" with "Microsoft.WindowsAzure.Storage.dll" (both name and version are different), this configuration is not needed at all.

MVC 4 Can't fix the error The type 'System.Web.Mvc.WebViewPage <TModel> exists in the elements

after moved my MVC 4 project from VS 2012 to VS 2013 Community I get the following error (in the LogIn.cshtml page).
CS0433: The type 'System.Web.Mvc.WebViewPage "exists in the elements c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll and c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll
I deleted all files from C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files, cleaned the solution but the problem remains. How to fix it ?
EDIT
The Test project used the MVC 3, that was the reason
If you have already tried the above solutions and are still getting the same problem then try this one->
Go to your project folder and in there locate the bin folder --> Remove System.Web.Mvc.dll and System.Web.Mvc.xml from there.
You could check in your web.config files.
Check if the version is the same as you're using as reference.
Application web.config file:
<add assembly="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
and
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
And the Views web.config file:
<add assembly="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
In my example, my MVC dll is the version 3.0.1. But Visual Studio built my solution as if it were 3.0.0. So I had to map the references in the web.config files to 3.0.1.
Check if you are referencing both DLLs to your project.
Your project is reading in two assemblies that might be referenced in your project:
System.Web.MVC version 4.0.0.0 and in System.Web.MVC version 3.0.0.0
In your root web.config, near the bottom, you will have something like the following:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
For me, I simply changed the 'oldVersion' number to 1.0.0.0-4.0.0.1 so that this application will always use the 'newVersion'.

How to use app.config file with a C++/CLI to configure assembly binding in VS 2012?

I am currently using the Microsoft BCL Async library (here) across a project with a large number of interdependent assemblies all compiled against .NET 4 Full Profile, I have had to use assembly binding redirect in each project to get it to compile (as per issue 2 here).
The problem I now have is that I consume one of these libraries from a C++/CLR DLL project, it does not actually need to use async but I have the following compilation error:
2>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3268: The primary reference "ImInterface.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "ImInterface.dll" or retarget your application to a framework version which contains "System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
I have added the same app.config file that I have used in all of the C# projects but it does not seem to be having any effect in the C++ project. Do I have to place it in a specific directory or perform any other steps to enable the app.config file to be recognised?
The content of my app.config file is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.11.0" newVersion="2.5.11.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.11.0" newVersion="2.5.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Any suggestions are appreciated!
Regards,
Anthony
I had the same problem and as it turned out, <SpecificVersion>True</SpecificVersion> helped.
Before you continue reading, note that the problem seems to only happen when the C++/CLI project is built using the "Visual Studio 2012 - Windows XP (v110_xp)" platform toolset! That is if you don't need to create a DLL which is compatible with WinXP, switch to "Visual Studio 2012 (v110)" instead and you should be fine.
Let me elaborate my scenario:
I have a C++/CLI console application project (ConsoleAppCLI) targeted for WinXP (v110_xp). ConsoleAppCLI references a library (AsyncLib) which has Microsoft.Bcl.Async installed via NuGet:
[ConsoleAppCLI.vcxproj] (C++/CLI, .NET 4.0 v110_xp)
|
|
[AsyncLib.csproj] (C#, .NET 4.0)
|
|
[Microsoft.Bcl.Async] (via NuGet)
I had the exact same problem and the app.config didn't help either, but what did help was the following:
Unload ConsoleAppCli.vcxproj
Edit the vcxproj File directly
Find the reference to the library which has the Async nuget package installed (in my case, a <ProjectReference> to AsyncLib.csproj)
Between <ProjectReference> and </ProjectReference>, ADD THE FOLLOWING: <SpecificVersion>True</SpecificVersion>
Note however, that ConsoleAppCLI was my top-level project in the dependency tree. If you have Assemblies which depend upon the C++/CLI assembly which produced MSB3268, you likewise have to add <SpecificVersion>True</SpecificVersion> to the reference (e.g. if i had an additional C# library which has ConsoleAppCli as dependency, i would have to make the reference to ConsoleAppCli <SpecificVersion>True</SpecificVersion> as well).
This solution is coming from over here, by the way.

Could not load file or assembly Telerik.Sitefinity

having some issues upgrading my Sitefinity 4.1.1339.0 installation to 4.3 (and ultimately to Sitefinity 5). It is giving me the following error:
Could not load file or assembly 'Telerik.Sitefinity, Version=4.1.1339.0, Culture=neutral, PublicKeyToken=b28c218413bdf563' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I was thinking it was the /bin/Telerik.Sitefinity.dll file but everything seems to be updated in there.
Any ideas?
Thanks!
I agree with #Josh, plus you might try looking through all your files in the App_Data\Sitefinity\Configuration folder. I had to update all of the references in those files manually for some reason to match the exact DLL version. Make sure you completely restart your cassini/IIS/sitefinity instance to pick up the changes.
If you are using 'assemblyBinding' in your Sitefinity web.config, you will need to update that section of the config to the latest dll versions. Assembly Binding is a common solution to map out of date third party Sitefinity modules/plugins to the current Sitefinity dlls.
The following are correct versions for Sitefinity 5.1.3210. Note that Telerik.Web.UI is a different version as it is from a different Telerik product line.
<!-- From web.config - not complete file -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Telerik.Sitefinity" publicKeyToken="b28c218413bdf563" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.1.3210.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Telerik.Sitefinity.Model" publicKeyToken="b28c218413bdf563" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.1.3210.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2012.2.607.40"/>
</dependentAssembly>
</assemblyBinding>
If you will be upgrading through many versions 4.1 -> 4.4 -> 5.0 -> 5.1, you may wish to comment out this section of the config until you are complete with your upgrades, then add it back in. Otherwise, you'll have to edit these three lines after each upgrade.
Note: to get the dll version, browse to the bin folder. Right click dll file, click properties, then select the 'details' tab.

Cache provider for NHibernate 2.0.1.GA using ASP.NET Cache object

I have migrated my application from NHibernate 1.2.1 to NHibernate 2.0.1. Now i am geting the error "Version Conflict error while compiling". It shows that application still using the NHibernate V1 but i have changed the Version by deleteing the old dll and added the new dll in application refference.
The only thing i have not changes is NHibernate.Caches.SysCache.SysCacheProvider and it is still pointing to the old version "1.0.1".
How could i migrate this, please help me
-Gunasekaran sambandhan
NHibernate.Caches is part of the contrib package. You need to download the latest version and update your assembly.
U can use an Assemmbly redirect provided in your application config file or the webconfig file like this
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.0.2001" newVersion="2.1.0.1002"/>
</dependentAssembly>
</assemblyBinding>
</runtime>