visual studio express 2012 app.config remapping assembly - visual-studio-2012

I moved a project from MVC 3 to MVC 4 a while ago now.
when I build, I get the messages
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0 ..." and , Version=2.0.0.0
1> Consider app.config remapping of assembly "System.Web.WebPages ..." from Version "1.0.0.0" to Version "2.0.0.0" to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Razorfrom Version "1.0.0.0" [c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\OEM\documents\visual studio 2012\Projects\DabTrial\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
and so on.
When I look at references, they are all the later versions, and the web.config only refers to the later versions. When I search the entire solution directory by the public key token (in windows explorer) I find no XML type files with references to the earlier versions.
obviously the path to the files is different, but I cannot find where the compiler is being directed to the path for the earlier .dll file.
The project builds and runs fine, but I assume the compiler is suggesting these changes for a reason. Thanks for any help.

Your nuget dependencies are probably referencing the MVC3 version. You can try putting the following into your web config to force the MVC4 version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
You could also try running the following in the Package Manager Console
Update-Package -Reinstall
You have to have at least version 2.1 of nuget for this command but it will update your packages and retarget them if you have updated .NET. You can check this post for more information.
Retargeting solution from .Net 4.0 to 4.5 - how to retarget the NuGet packages?

I also had such problems. I did just two things:
updated System.Web.Mvc and all dependencies to the last version (5.2.3)
Rebuild all solution (I did using "Solution -> Clean Solution", then "Solution -> Build Solution")

Try setting AutoGenerateBindingRedirects to true in the project file.

Related

ASP.NET Boilerplate MVC 5.x template fails to start

After downloading ASP.NET MVC 5.x template, I update the connection string, restore NuGet packages and then try to run Update-Database command in Package Manager Console, but I consistently get the following error:
Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I was able to solve this once by removing all packages and adding them back one at a time, but this is extremely time-consuming.
I have had this same experience with both the Angular and Multipage versions, and I am using VS2017 Community.
What am I doing wrong?
in the Web project's web.config it reads:
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
You can remove that binding redirect.

Building Visual Studio C++ solution 2015 failed using TFS 2013 team build

We have TFS build machine configured to build source code from TFS. On this machine we had Team Foundation Server 2013 together with Microsoft Build Tools 2013 installed and then recently, we installed Microsoft Build Tools 2015. In the build defintion, we put /tv:14.0 for MSBuild arguments to indicate we want to use version 14.0 of MSBuild. Also, we set the perform code analysis to be false so that it won't perform code analysis.
However, when we queue a build, it failed with given errors:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The source file for this compilation can be found at: "C:\Users\tfsservice\AppData\Local\Temp\b54ca1bb-e696-4214-a196-5c79c32345cd.txt"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): An error has occurred during compilation. error CS1705: Assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin\amd64" directory.
Does anybody experience this issue before?
It seems like the Microsoft.Build.Utilities.Core was referenced to the incorrect version of Microsoft.Build.Framework.
However, in MSBuild.exe.config, this assembly is redirected corectlly
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="14.0.0.0"/>
</dependentAssembly>
Any helps are appreciated.
P.s. The solution we want to build is a visual c++ solution upgraded from VS 2013 to VS 2015.
Seems that many other community members have the similar issue, the /tv:14.0 argument doesn't work. Check this link for the detailed information.
The workaround is: instead of using the /tv:14.0 argument, you need to customize the tfs build process template to set ToolPath of the Run MSBuild for Project to target to MSBuild14; and set ToolVersion to "14.0".

Microsoft.SqlServer.Types, Version=11.0.0.0 missing

I have published the project on Azure websites and it throws exception:
Microsoft.SqlServer.Types, Version=11.0.0.0 missing when I try to
run report. Locally everything works fine. I have
RepowrtViewer.WebForms and ReportViewer.Common both version 11.0.0.0
in the project. On the machine locally in SDK/Assemblies
I have Microsoft.SqlServer.Types, Version=11.0..2100.6. I have tried to add this to the project but did not work. The same exception,
Where do I find Microsoft.SqlServer.Types 11.0.0.0?
Thank you
You're probably referencing the DLL's from the global assembly cache on your local machine but they aren't present in the GAC in Azure.
Open up visual studio and right click on the Microsoft.SqlServer.Types assembly reference in your project and select properties. Change the copy local flag from False to True and recompile your application. You should now have the the Microsoft.SqlServer.Types.dll file in your applications bin folder.
Redeploy to azure and hopefully the error will have vanished.
How I got this solved.
I had to add 5 files altogether and I moved these 5 files to my bin directory. I then added these references by browsing to the bin directory and adding them. I rebuilt my project and copied to web server - all working fine.
Microsoft.SqlServer.Types.dll (make sure you copy the correct version as I had sql 2008 but using report viewer 11)
Microsoft.ReportViewer.ProcessingObjectModel.dll
Microsoft.ReportViewer.Common.dll
Microsoft.ReportViewer.WebForms.dll
Microsoft.ReportViewer.WinForms.dll
Also make sure you have the correct version of these dll's from the GAC in the bin directory and I installed report viewer on the server. These are the steps that worked for me.
The best solution would be to install the Microsoft.SqlServer.Types NuGet package.
PM> Install-Package Microsoft.SqlServer.Types
And follow instructions from its readme.htm
I had exactly the same issue but found the solution quite quickly. It was using the Assembly within this folder C:\Program Files (x86)\Microsoft SQL Server\100 where I then removed my reference via Visual Studio and referenced the right file from within this folder C:\Program Files (x86)\Microsoft SQL Server\110
If you still need this reference then please make use of this method.
Cheers,
Check your SQL server ProductVersion using the following query,
SELECT
SERVERPROPERTY('MachineName') AS ComputerName,
SERVERPROPERTY('ServerName') AS InstanceName,
SERVERPROPERTY('Edition') AS Edition,
SERVERPROPERTY('ProductVersion') AS ProductVersion,
SERVERPROPERTY('ProductLevel') AS ProductLevel;
GO
It will be like something this,
You can see in my case ProductVersion = 13.0.1601.5. In your project go to NuGet package manager and search Microsoft.SqlServer.Types. From there you can see, Microsoft.SqlServer.Types with the same ProductVersion and Install it.
My Experience
I used to face this kind of problems until I understand the GAC and Bin deploy
Your computer has all the installed DLLs into a place called GAC (Global Assembly Cache). so your local programs can search for their needs in there if they can not find the required DLL in the execution path. It's often work for developer itself, but when you deploy your program to the client, problems may appear.
Remember that, you can always Bin deploy your DLLs. first, go to the references tree in your project and add the required Dll by browsing your GAC (usually c:\windows\assembly\GAC_MSIL...) then go to the property window of the added Dll and set Copy Local to True . Now you can publish or deploy your project and be sure that it will works.
Make sure you are not missing a binding redirect
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
<bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
</dependentAssembly>
https://www.microsoft.com/en-us/download/details.aspx?id=56041
Download from here if this needs to be installed in your machine

Error doing web.config transformation for different environments

I was trying to deploy my app into different environments then i started following this how to:
Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio or Visual Web Developer: Web.Config File Transformations - 3 of 12
was perfect until I clicked in Preview Transform, I received this error:
Microsoft Visual Studio
Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
(I created just one transformation Web.DebugQA.config and of course the default ones, debug and release)
my Web.DebugQA.config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
</system.web>
<appSettings>
<add key="EnvironmentName" value="QADev" xdt:Transform="SetAttributes(value)"
xdt:Locator="Match(key)" />
</appSettings>
</configuration>
but then I install this plugin:
SlowCheetah - XML Transforms
and I solved my preview transform error, but then when I was trying to publish using the QADev transform I got this error:
The "ImportParametersFile" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Web.Publishing.Tasks.ImportParametersFile.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
I'm using Visual Studio Pro 2012.
I fixed this by repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel --> Programs and Features.
The file Microsoft.Web.XmlTransform.dll was missing from the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web.
I had a similar error, although it was caused for different reasons.
I solved it copying the following DLL from another PC with VS2012 installed:
Microsoft.Web.XmlTransforms.dll
from: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
I hope this helps
I had same problem in VS2012, could not 'Preview Transform' for the PublishPackage tranforms e.g. Web.Staging.config complaining about Microsoft.Web.XmlTransform
I got it working by adding the Package https://nuget.org/packages/Microsoft.Web.Xdt to my Mvc 4.5 project. This package is still in pre release.
PM> Install-Package Microsoft.Web.Xdt -Pre
This package contains the Microsoft.Web.XmlTransform.dll
I still get an error during building complaining about "Could not load file or assembly Microsoft.Web.XmlTransform". The Mvc project has still built ok.
I did try adding the Microsoft.Web.XmlTransform.dll to the Gac using the gacutil but that did not fix the problem.
However I use Team Foundation Service build server and it works and creates the correct Web.config after applying the Web.Release.config and then the Web.Staging.config.
I tried below two things but it did not work for me.
1) copying the Microsoft.Web.XmlTransforms.dll DLL to location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
2) And repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012"
Then I uninstalled Microsoft Azure tool V2.6 from control panel -> Programs and Features. And then I can able to publish my site.
This may have been fixed in Visual Studio 2012 Update 2 (and Visual Studio 2013).
Web.config "Preview Transform" gives an error
...
Posted by Microsoft on 3/1/2013 at 2:46 PM
Thanks for reporting the issue! It will be fixed in Visual Studio 2012 Update 2. Please install it when it becomes available.

Error thrown when I'm trying to load log4net assembly

I'm try to build project that use LinqToExcel library. Additionally, I'm use log4net to write logs.
My problem started when I'm tryomg to run this lines of code:
var excel = new ExcelQueryFactory(ExcelPath);
return (from r in excel.Worksheet<RowDetails>(company.Name)
select r).Count();
This line thrown exception:
ERROR MyProj.Program Main:System.IO.FileLoadException: Could not load
file or assembly 'log4net, Version=1.2.11.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name: 'log4net,
Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'
It's important to note that I'm successful to use log4net before this line.
I would appreciate any help.
Thanks a lots!
As marc_s pointed out, this problem usually appears when trying to load different versions of the same assembly. Make sure, that your project uses the same assembly version as the LinqToExcel library, which is also dependent on log4net. Also any other libraries should use the same assembly version. To solve the issue, you can also try to use assembly redirect in your app.config like so:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="1.2.10.0" newVersion="1.2.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
try to install it using nuget
Install-Package log4net -Version 2.0.0
Version 2.0.0 is for log4net 1.2.11
I'm having similar problem. I think that the problem is in LinqtoExcel referencing Log4Net version 1.2.11, and you have referenced Log4Net sepratly and you get latest 1.2.13 version. In build output you'll end up with 1.2.13, and when LintoExcel calls Log4Net it expects 1.2.11 and error ocures.
I got this issue after upgrading log4net through NuGet, only to find that the newer version was signed with a different key.
You can grab the 'oldkey' version from the apache log4net site and then it worked for me.

Resources