Question

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.


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?

Was it helpful?

Solution

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

OTHER TIPS

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.

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..

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

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.

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.

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.

Reinstall .Net Framework 2.0.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top