views:

768

answers:

10

Bounty: I will send $5 via paypal for an answer that fixes this problem for me.

I'm not sure what VS setting I've changed or if it's a web.config setting or what, but I keep getting this error in the error list and yet all solutions build fine. Here are some examples:

Error   5 'CompilerGlobalScopeAttribute' is ambiguous in the namespace 'System.Runtime.CompilerServices'. C:\projects\MyProject\Web\Controls\EmailStory.ascx 609 184 C:\...\Web\
Error   6 'ArrayList' is ambiguous in the namespace 'System.Collections'. C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 13 28 C:\...\Web\
Error   7 'Exception' is ambiguous in the namespace 'System'. C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 37 21 C:\...\Web\
Error   8 'EventArgs' is ambiguous in the namespace 'System'. C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 47 64 C:\...\Web\
Error   9 'EventArgs' is ambiguous in the namespace 'System'. C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 140 72 C:\...\Web\
Error   10 'Array' is ambiguous in the namespace 'System'. C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 147 35 C:\...\Web\

    [...etc...]

Error   90 'DateTime' is ambiguous in the namespace 'System'. C:\projects\MyProject\Web\App_Code\XsltHelperFunctions.vb 13 8 C:\...\Web\

As you can imagine, it's really annoying since there are blue squiggly underlines everywhere in the code, and filtering out relevant errors in the Error List pane is near impossible. I've checked the default ASP.Net web.config and machine.config but nothing seemed to stand out there.

Any help or suggestions would be appreciated, thanks!

Edit: Here's some of the source where the errors are occurring:

'Error #5: whole line is blue underlined'
<%= addEmailToList.ToolTip %>

'Error #6: ArrayList is blue underlined'
Private _emails As New ArrayList()

'Error #7: Exception is blue underlined'
Catch ex As Exception

'Error #8: System.EventArgs is blue underlined'
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

'Error #9: System.EventArgs is blue underlined'
Protected Sub sendMessage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles sendMessage.Click

'Error #10: Array is blue underlined'
Me.emailSentTo.Text = Array.Join(";", mailToAddresses)

'Error #90: DateTime is blue underlined'
If DateTime.TryParse(data, dateValue) Then

Edit: GacUtil results

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\gacutil -l mscorlib

Microsoft (R) .NET Global Assembly Cache Utility.  Version 1.1.4318.0
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

The Global Assembly Cache contains the following assemblies:

The cache of ngen files contains the following entries:
        mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c5619
34e089, Custom=5a00410050002d004e0035002e0031002d003800460053002d003700430039004
40037004500430036000000
        mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c5619
34e089, Custom=5a00410050002d004e0035002e0031002d0038004600440053002d00370043003
900450036003100370035000000

Number of items = 2
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil" -l mscorlib

Microsoft (R) .NET Global Assembly Cache Utility.  Version 2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:

Number of items = 0

Edit: interesting results from ngen:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ngen display mscorlib /verbose

Microsoft (R) CLR Native Image Generator - Version 2.0.50727.832
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

NGEN Roots:

mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=5a00410050002d004e0035002e0031002d003800460053002d00330037004200430043003300430035000000 
    ScenarioDefault 
        mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=5a00410050002d004e0035002e0031002d003800460053002d00330037004200430043003300430035000000 
            DisplayName = mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
            Native image = {7681CE0F-F0E7-F03A-2B56-96345589D82B}
            Hard Dependencies:
            Soft Dependencies:
mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
    ScenarioNoDependencies 
        mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
            DisplayName = mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
            Native image = {7681CE0F-F0E7-F03A-2B56-96345589D82B}
            Hard Dependencies:
            Soft Dependencies:

NGEN Roots that depend on "mscorlib":
[...a bunch of stuff...]

Native Images:

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 Source MVID: {D34102CF-2ABF-4004-8B42-2859D8FF27F3}
 Source HASH: bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec
 NGen GUID sign: {7681CE0F-F0E7-F03A-2B56-96345589D82B}
 OS:  WinNT
 Processor: x86(Pentium 4) (features: 00008001)
 Runtime: 2.0.50727.832
 mscorwks.dll: TimeStamp=461F2E2A, CheckSum=00566DC9
 Flags:  
 Scenarios:  <no debug info> <no debugger> <no profiler> <no instrumentation> 
 Granted set: <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/>

 File:  

C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\0fce8176e7f03af02b5696345589d82b\mscorlib.ni.dll
 Dependencies:
  mscorlib, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089:
   Guid:{D34102CF-2ABF-4004-8B42-2859D8FF27F3}
   Sign:bbf5cfc19bea4e13889e39eb1fb72479a45ad0ec

There should only be one mscorlib in the native images, correct? How can I get rid of the others?

A: 

When asking for help diagnosing compilation problems, it often helps to post the offending source code :)

These errors really mean that the specified name conflicts with another and the compiler cannot resolve this. It does look a little odd tho..

Andrew Grant
A: 

I've been hit by this as well, specifically System.Data.SqlClient. Try unchecking namespaces in the Project manager and manually including them in the .vb file, like you would with C#:

Imports System.Data.SqlClient

swilliams
A: 

Take one error (like ArrayList) and replace the type with the full-qualified name (I'm not sure, but I guess here: System.Collection.ArrayList). If the error vanishes, you really have a resolving conflict. If not, it's something else.
If all solutions build "fine" with these errors, I suggest cleaning your projects. Delete all compiled stuff (dll, pdb, whatsoever), also shadow cached ones. Maybe it compiles because it uses an old version of something.

John Smithers
A: 

Thanks for all the suggestions so far, they didn't fix the main issue, however it's good to rule them out as potential problems.

@Andrew I've added the offending lines of code in the post.

@swilliams I've tried this, but unfortunately it didn't help.

@John Smithers I've tried that as well, but as you can see above System.EventArgs still causes an error. These errors even occur on new projects, so there must be some global setting I'm missing.

I'm thinking that there must be some kind of double reference to the main dlls for the common namespaces or something or possibly some option to be more strict about the name space definitions. Or something like that. :-/

travis
A: 

I know this sounds odd, but do you use "Build" or "Rebuild" to build the solution? If I have funny problems like that, a "Rebuild All" to the solution helps.

John Smithers
A: 

@John Smithers I just tried that and I still get a successful build, but all the same errors in the Error List pane. Thanks for the suggestion though.

FWIW, I've been getting these same errors for months on existing, new from source control, and brand new projects. They're maddening, and googling has helped very little.

travis
+1  A: 

I had the same error recently. Here's how I fixed it (I hope it works for you too):

-Open your project properties, go to the references section.

-Remove the reference to System in the upper section.

I think it's referencing System twice but it's only showing once. Hence the ambigous references.

Spell
Unfortunately there is no System listed in the references. I wonder if there is some global references setting in VS where there might be a duplicate reference though...
travis
What are the References listed? What's in the GAC when you run this: C:\>gacutil -l mscorlib
Richard Morgan
The references listed are all the other projects in the solution, I'll try running that GACutil...
travis
OK, I've pasted the results in the description, looks promising.
travis
+1  A: 

Based on the results of your gacutil output (thanks for doing that; I think it helps), I would say you need to try and run a repair on the .NET Framework install and Visual Studio 2005. I'm not sure if that will fix it, but as you can see from the output of the gacutil, you have none for 2.0.

From my VS2005 Command Prompt, I get:

Microsoft (R) .NET Global Assembly Cache Utility.  Version 2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

The Global Assembly Cache contains the following assemblies:
  mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86

Number of items = 1

From my VS2003 Command Prompt, I get:

Microsoft (R) .NET Global Assembly Cache Utility.  Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

The Global Assembly Cache contains the following assemblies:

The cache of ngen files contains the following entries:
    mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=5a00410050002d004e0035002e0031002d003800460053002d00330037004200430043003300430035000000
    mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=5a00410050002d004e0035002e0031002d0038004600440053002d00330037004200440036004600430034000000

Number of items = 2
Richard Morgan
I've updated the description again with my ngen results.
travis
When I run it on a machine without this problem, there is only one mscorlib listed. Any tips on removing the duplicates?
travis
Did the repair not work?
Richard Morgan
no, I don't have permissions to run the repair tool on the problem machine unfortunately.
travis
@Richard: Unfortunately, the power supply on the machine having this issue has died, thus it will be a mystery as to what the actual solution would be, but since I believe this was the closest answer, you get the points and the $5 via paypal to you or the charity of your choice. Just let me know where to send it :-)
travis
@travis: No worries, mate. Glad the problem "fixed" itself. :)
Richard Morgan
A: 

Yesterday I got the same in VS2005 ASP.NET web site project: suddenly, with any previous significant code change, loads of 'x' is ambiguous in the namespace 'y' appeared, all of them originated from very fundamental symbols, like EventArgs, Type, DBNull, etc.

Immediate reason of that is double-referenced mscorlib, as I can see in VS's Class View. The true reason, I believe, is the automatic Windows Update which had forced me to restart the machine minutes before.

Trying such stunts like establishing a brand new ASP.NET web site project, copy-paste the source text on it (on the same machine - doesn't help) or move the project on the second machine with the same VS2005 installation (it helps, project works normally) I'm nearly sure there is nothing wrong with my code, but with my VS/.NET configuration. And I desperately don't know how to cure it, as there is no trace on the Internet describing similar troubles, apart from this one.

A: 

Reinstall .Net Framework 2.0.

That should fix it. Afterwards, gacutil (from v2.0) would show 1 mscorlib and not 0.

configurator