I've just migrated my ASP.NET MVC 3 application from windows 7 /VS2010 to Windows 8 / Visual Studio 2012. I'm getting a weird Code Analysis error.
CA0055 Error Running Code Analysis CA0055 : Could not load MyAssembly.dll. The following error was encountered while reading module 'System.Web.Mvc': Could not resolve type reference: [System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]System.Web.Razor.Parser.SyntaxTree.CodeSpan. [Errors and Warnings] (Global)
Adding a reference to System.Web.Razor did not help. Work-around for now is to disable code analysis for the web project. Does anyone know why this error occurs and/or how to fix it?
My guess is that MyAssembly.dll references another System.Web.Razor version compared with the one you have in your project.
Can also be different .Net frameworks in different projects.
Related
Our project (.Net Framework 4.6.2) was chugging along just fine on EF Core 1.1.0. Then we decided to upgrade to EF Core 2.0.0. Went through a few days of tweaking the code to use new syntax, getting our unit and integration tests to pass again, and finally they did. So today we deployed onto our QA site, which immediately broke with a DLL Hell message:
Could not load file or assembly 'System.Net.Http, Version=4.0.0.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)
During the course of the upgrade I had updated System.Net.Http from 4.3.0 to 4.3.3, so I tried reversing that. Didn't help. I tried commenting out the dependent assembly reference in web.config, and that made the message change:
Could not load file or assembly 'System.Net.Http, Version=4.1.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)
Hello! If I've understood correctly, that means that version 4.1.1.0 of System.Net.Http (which is the correct one) is actually being found by the binding redirect - but there's some other assembly that's coming along with my deployment, which is looking for version 4.0.0.0, and ignoring the binding redirect.
How do I find which assembly is messing me up? And how do I get it to respect the binding redirect?
Apparently I'm not the only person to have been sucker-punched by this issue. See here, here and here.
TLDR: Visual Studio 2017 comes packed with a bunch of the latest and greatest DLLs, which are so very good, that MSBuild will impose them on you if you're working with .NET Framework 4.6.2 or earlier, because why would you want to use those cobwebby old versions that you specified in your binding redirects?
I've tried two solutions that worked:
Quick & dirty: Go into your Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461 folder. You'll find lib and ref folders there. Go into each of these and create a subfolder called HideMe or suchlike. Then move all the DLLs except netstandard.dll into the HideMe folder. Now MSBuild can't impose its ideas of which DLL is best for you.
The proper way: Upgrade to .NET Framework 4.7.1. That will be a little more labor-intensive and might break stuff, but at least you don't have to do hacks like my first workaround.
I am using entity framework power tools 4 (beta). My project uses asp.net identity and EF 6.1.2. I have updated all the entity framework dlls via nuget. When I attempt to pre generate a view with EF Powertools for my dbcontext i receive the error :
Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
I have updated my EF to 6.1.2 so it is the latest.
Has anyone else experienced this issue and solved it. I've seen people on the EF Powertools site posting similar issues to this but there's no solution I can find.
Thanks
UPDATE : - I have reinstalled all the packages with no luck. I have even gone as far as giving the solution to someone else to install on their pc - and they can run it and generate the views using power tools without the error. So it's probably something to do with my environment. Any ideas what to try changing ?
The IndexAttribute is a new feature that is added in Entity Framework 6.1.
You say that you have updated to 6.1, but the error suggests that you have a reference to version 6.0.
Can you remove all references to EF and System.Data.Entity and then try to install it again with Nuget?
The reason is that Power tools use the IDE version of EntityFramework and not the referenced. Please check my solution EntityFramwork Power Tools error while generating views
I've been trying to run my build on TFS and I keep getting an error that kills my build. What's strange is that nothing except code change has been done since the issue started (Or at least that I'm aware about). I keep seeing this:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.WinFx.targets (268): Unknown build error, 'Cannot resolve dependency to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.'
I've googled this and the only thing I see is that it's because there's a Silverlight dll being used in a WPF application. My application is a WPF project, but I haven't been able to find any changes being done in any of my projects in my solution in regards to references.
For more information, this project is a branch from the main code. The main development branch runs fine, but for some reason, this build just fails.
Any ideas?
It seems like you're referencing the Silverlight version of System.Windows instead of the .NET Framework version. Have you tried installing Silverlight on the build server or changing the reference of your project to point to the normal .NET Framework version of that assembly (which .NET Framework exists on your build server)?
I have attempted to create an MVC 5 project by creating an MVC 4 project in Visual Studio 2012 and installing MVC 5 through Nuget.
I can build this fine.
I attempt to add a reference to another DLL, Sitecore.Mvc.DLL, which I can see was built against MVC 5.1.0. The DLL reference is added fine, and there seems to be no .NET framework conflict (which is where I've seen this issue in the past).
I'm trying to add a using statement to my code:-
using Sitecore.Mvc.Presentation;
IntelliSense picks this up fine....even allowing me to auto-complete 'Presentation'.
However when I build I get the following error:-
The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?)
What could be the issue here?
I'm using:-
Visual Studio 2012 - Update 4
MVC 4 Web Application (initially)
MVC 5.1.0 Nuget Package
Sitecore 7.2 - Update 2 (where Sitecore.Mvc.DLL comes from)
.NET 4.5.2 installed on my machine.
Turns out I'm using a different version of Sitecore.Mvc.DLL, which IS targeted to .NET 4.5.1. Seems like the mscorelib reference in Reflector doesn't quite tell all the details.
Now I need to target my Web App to .NET 4.5.1, which means I need to follow the steps here to be able to select it.
http://blogs.msdn.com/b/dotnet/archive/2013/08/08/building-apps-with-the-net-framework-4-5-1-preview-in-visual-studio-2012.aspx
Thanks, and sorry to #Khanh TO, and everyone else for helping out.
I am using WSPBuilder on Visual Studio 2010 to create a feature with a feature receiver assembly for SharePoint 2010. When I try to build the WSP using WSP Builder I get this message in the output window:
The assembly MyAssembly.dll is unmanaged. The assembly will be excluded from the WSP package!
The defined Project Assembly seems not to be a valid assembly!
Solution compatibility: SharePoint 2010
The resulting WSP that gets built does not contain my DLL.
My DLL is strongly named, and I cant think of any other obvious reasons why this is happening.
Any idea why WSPBuilder is not able to package my assembly in the WSP?
Ahh... Found the answer. My code was getting compiled against .Net Framework 4.0. Changed it to .Net Framework 3.5 and Voila! WSP gets built without any problems...