warning C4945 considerably slowing down build

G

Guest

I'm trying to migrate a solution from .NET 1.1 to 2.0 (Visual Studio 2003 to
VS 2005), and I'm getting a ton of "warning C4945" messages. I am not using
MSBuild, I'm just doing a build from within VS 2005. Based on suggestions
from other forums, I tried setting "Copy Local" to false for all references
in all projects, but that didn't help. Any idea what's causing these
warnings? They did not occur in VS 2003.
 
J

Jon Skeet [C# MVP]

KevinMurphyRJLG said:
I'm trying to migrate a solution from .NET 1.1 to 2.0 (Visual Studio 2003 to
VS 2005), and I'm getting a ton of "warning C4945" messages. I am not using
MSBuild, I'm just doing a build from within VS 2005. Based on suggestions
from other forums, I tried setting "Copy Local" to false for all references
in all projects, but that didn't help. Any idea what's causing these
warnings? They did not occur in VS 2003.

Have you seen
http://blogs.msdn.com/msbuild/archive/2006/07/10/661747.aspx
and phoned support for the Hotfix?
 
G

Guest

Thanks, Jon. I applied the hotfix and my build goes much faster now. I was
under the impression that the hotfix would get rid of the warnings, but I'll
take the speed up. Build time went from about an hour to a few minutes.
 
G

Graeme Swallow

I recently had a C++/CLI project start throwing 351 instances of the C4945 warning on me. The project references 3 C# assemblies, "A", "B", and "C". I suspect the problem comes in because both assembly "C" and the main app reference assembly "A". So when symbols from assembly "A" are imported into the main project at compile time, those warning get thrown because those symbols already exist via assembly "C"'s reference to assembly "A". Hence the message text: "Cannot import symbol ... from assembly ... because the symbol was already defined in assembly ..."

Microsoft's KB922271 article suggests setting "Copy Local" and "Copy Local Dependencies" to false, which accomplishes nothing in this case -- nor does installing the related hotfix.

What I stumbled upon was that setting the "Copy Local..." options back to "true" and setting the "Use Dependencies in Build" and "Use In Build" options to "false" solves the problem. From there, I would guess that taking the reference to assembly "A" out of the main project would also solve the problem, though I haven't tried it yet.

The weird thing is that I have two machines on which I develop this project. Only one of them ever generated this warning message. So I'm not sure what the internals are that cause this message to/not to show up.

But the bottom line is that I would check your references, and see if you have two projects in your solution both referencing a third assembly. That seems to be the root cause.

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
K

KevinMurphyRJLG

Changing "Use In Build" to false caused some compile errors, but changing
only "Use Dependencies In Build" to false got rid of all the C4945 warnings.
Thanks a lot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top