CS1685:

So I’ve been playing with some C# in trying to mess with other stuff in some insane fun.  Anyways I was getting this weird compiler error trying to build my c# components:

warning CS1685: The predefined type ‘System.Func’ is defined in multiple
assemblies in the global alias; using definition from
‘c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll’

Well that is strange.  Everything still worked, but I was getting screens full of this crap, so I was missing anything that didn’t build correctly from the CLI, so I had to find the source.  I found this nice tip, by adding the following into the source, and compile again.

System.Runtime.CompilerServices.ExtensionAttribute x = null;

And running the compiler (yet again), I got this:

c.cs(17,33): error CS0433: The type
‘System.Runtime.CompilerServices.ExtensionAttribute’ exists in both
‘d:\proj\zmq.net\b\System.Core.dll’ and
‘c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll’
System.Core.dll: (Location of symbol related to previous error)
c:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll: (Location of symbol
related to previous error)

What is this? There is a System.Core.dll in my work area?

11/05/2010  09:53 AM           667,648 System.Core.dll

Sure enough, there it is.  I don’t know why it’s there, I don’t remember putting it there.  Even though I wasn’t directly referencing it, for some reason it was getting pulled in.

D:\proj\zmq.net\b>c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc c.cs /r:netm
q.dll
Microsoft (R) Visual C# Compiler version 4.0.30319.18408
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

c.cs(17,52): warning CS0219: The variable ‘x’ is assigned but its value is never
used

Now I can delete the added line, and I’ll get a silent compile.

Yay.

One thought on “CS1685:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.