28
votes

I have an MVC3 project that I upgraded from VS2010 to VS2012. The project also has a reference to MiniProfiler. Our application compiles and runs fine in VS2012 without any warnings/errors. Both assemblies load fine when running with IIS Express. When using the ASP.NET Compiler tool, however, I get the following warning:

Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.17929 Utility to precompile an ASP.NET application Copyright (C) Microsoft Corporation. All rights reserved.

(0): warning : The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: MiniProfiler, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3. The dependencies are: System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly.

We don't have an explicit reference to System.Data.Linq. Up until the update to VS2012, we didn't have any errors. The MiniProfiler version is indeed targeting .NET 4.0 (as is our application). What could be causing this warning?

2
I've had a look at the setups, and I can't see anything obviously wrong that might cause this... - Marc Gravell
@MarcGravell - So what's really weird is that if I create a new project and use the same approach above, it'll work just fine... :( - TheCloudlessSky
Could check the bin directories for any funky dll's that could have ended up there? Also backup your obj folder then delete it from the project I find that helps with all kinds of oddities ;o) - Luke Baughan
@bUKaneer - It wouldn't be the obj folder since we run the aspnet_compiler outside of that directory structure. I also checked the pre-compiled bin folder and can't find anything odd.. :( - TheCloudlessSky
I seem to be having this same problem with a different pre-compiled project. All the assemblies are on .Net 4, but it complains about a mismatch of versions. - AJ Henderson

2 Answers

30
votes

I was finally able to fix it with a tip from this answer. I added the following <add> line in the web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <!-- etc... -->
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <!-- etc... -->
      </assemblies>
    </compilation>
  <system.web>
</configuration>
3
votes

Did you changed targetFramework inside Web.confing?