2

Inheriting a new project today, trying to make hundreds of warnings go away, and stumped on this. ASP.NET MVC 2, framework 4.0 project which compiles just fine in VS2010, but when the build process hands off to aspnet_compiler.exe, I get the following (cut and pasted from the Output window):

AfterBuild:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v temp -p C:\data\crecare\CreCare20110403\CreCare.Mvc\\..\CreCare.Mvc 
ASPNETCOMPILER : warning CS1685: The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll'

Both a search in the Object Browser and a tedious assembly-by-assembly review of the references in the project do not turn up any multiple definition. As far as I can tell the previous team did not try to build any extensions in previous ASP.NET versions (one cause of this error, I have learned ); I think this has targeted 4.0 from the start.

It's only a warning and I suppose I can ignore it (you can't even /nowarn with aspnet_compiler.exe, so I have to look at them) -- but it rubs me wrong. Any suggestions for how to hunt this down? Should that "\..\" in the path to the project worry me? I'm running 64-bit windows; it's not looking at the x86 and 64 at the same time?

It's worth noting that the using the Object Browser in VS2010 in the solution only finds the type in the assembly that aspnet_compiler.exe finds; a search for the type only gives one result. Is aspnet_compiler.exe looking in places that VS2010 doesn't?

bschuth
  • 135
  • 1
  • 8
  • I have a partial answer: this is using the [db4o](http://www.db4o.com) object database. The db4o assemblies use Mono.Cecil.dll; this does implement the ExtensionAttribute type as defined above. Mono.Cecil gets copied into the bin/debug directory. If I erase all Mono.Cecil.dlls and run aspnet_compiler, the warnings go away; I'm not sure if I've broken anything, though. I think I'm doomed to looking at these warnings. – bschuth Apr 27 '11 at 04:13
  • I think I found the solution. This is really a dup of [this previous question](http://stackoverflow.com/q/4353335/519048); I just didn't see it because the underlying reference to Mono.Cecil wasn't visible to me through VS2010; db4o was sneaking in the reference and I didn't realize it. The lesson: if you start getting weird answers from aspnet_compiler, look at what got pulled into your bin/debug folder, it may be the cause of your problem. To make this go away I need to recompile Mono.Cecil with the NET_4_0 symbol and replace any existing Mono.Cecil.Dlls with it. – bschuth Apr 27 '11 at 04:21

1 Answers1

1

Just like you said this is due to Mono.Cecil.

This warning can become an error if you do have a reference to Mono.Cecil.Dll and implement extension methods / because when doing the compiler gives precedence to the Mono.Cecil implementation.

I don't get why db4o assemblies that are supposed to be for .net 4 are not taking this into account, but we can confirm the same as we've looked into the same issue.

As long as you only copy to output the Mono.Cecil (we add as a link and set it to copy to output) instead of using a normal reference, all works fine. The warning is annoying, but given the weird situation around these assemblies on db4o, we preferred not dealing with building its source for now.

eglasius
  • 35,831
  • 5
  • 65
  • 110