2

赏金:我将通过贝宝发送 5 美元,以获得为我解决此问题的答案。

我不确定我更改了哪些 VS 设置,或者它是 web.config 设置还是什么,但我在错误列表中不断收到此错误,但所有解决方案都可以正常运行。这里有些例子:

错误 5“CompilerGlobalScopeAttribute”在命名空间“System.Runtime.CompilerServices”中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx 609 184 C:\...\Web\
错误 6 'ArrayList' 在命名空间 'System.Collections' 中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 13 28 C:\...\Web\
错误 7“异常”在命名空间“系统”中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 37 21 C:\...\Web\
错误 8 'EventArgs' 在命名空间 'System' 中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 47 64 C:\...\Web\
错误 9 'EventArgs' 在命名空间 'System' 中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 140 72 C:\...\Web\
错误 10 'Array' 在命名空间 'System' 中不明确。C:\projects\MyProject\Web\Controls\EmailStory.ascx.vb 147 35 C:\...\Web\

    [...ETC...]

错误 90 'DateTime' 在命名空间 'System' 中不明确。C:\projects\MyProject\Web\App_Code\XsltHelperFunctions.vb 13 8 C:\...\Web\

正如您可以想象的那样,这真的很烦人,因为代码中到处都有蓝色波浪下划线,并且在“错误列表”窗格中过滤掉相关错误几乎是不可能的。我检查了默认的 ASP.Net web.config 和 machine.config,但似乎没有什么突出的。


编辑:这是发生错误的一些来源:

'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

编辑:GacUtil 结果

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

Microsoft (R) .NET 全局程序集缓存实用程序。版本 1.1.4318.0
版权所有 (C) Microsoft Corporation 1998-2002。版权所有。

全局程序集缓存包含以下程序集:

ngen 文件的缓存包含以下条目:
        mscorlib,版本=1.0.5000.0,文化=中性,PublicKeyToken=b77a5c5619
34e089,自定义=5a00410050002d004e0035002e0031002d003800460053002d003700430039004
40037004500430036000000
        mscorlib,版本=1.0.5000.0,文化=中性,PublicKeyToken=b77a5c5619
34e089,自定义=5a00410050002d004e0035002e0031002d0038004600440053002d00370043003
900450036003100370035000000

项目数 = 2
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil" -l mscorlib

Microsoft (R) .NET 全局程序集缓存实用程序。版本 2.0.50727.42
版权所有 (c) 微软公司。版权所有。

全局程序集缓存包含以下程序集:

项目数 = 0

编辑:来自 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

本机映像中应该只有一个 mscorlib,对吗?我怎样才能摆脱其他人?

4

8 回答 8

2

我最近有同样的错误。这是我修复它的方法(我希望它也适用于你):

- 打开您的项目属性,转到参考部分。

-删除上部分对系统的引用。

我认为它引用了 System 两次,但它只显示一次。因此,模棱两可的引用。

于 2008-09-18T13:57:23.237 回答
1

根据您的 gacutil 输出结果(感谢您这样做;我认为它有帮助),我会说您需要尝试在 .NET Framework 安装和 Visual Studio 2005 上运行修复。我不确定这是否会修复它,但是从 gacutil 的输出中可以看出,2.0.0 没有。

从我的 VS2005 命令提示符中,我得到:

Microsoft (R) .NET 全局程序集缓存实用程序。版本 2.0.50727.42
版权所有 (c) 微软公司。版权所有。

全局程序集缓存包含以下程序集:
  mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089,处理器架构=x86

项目数 = 1

从我的 VS2003 命令提示符中,我得到:

Microsoft (R) .NET 全局程序集缓存实用程序。版本 1.1.4322.573
版权所有 (C) Microsoft Corporation 1998-2002。版权所有。

全局程序集缓存包含以下程序集:

ngen 文件的缓存包含以下条目:
    mscorlib,版本=1.0.5000.0,文化=中性,PublicKeyToken=b77a5c561934e089,自定义=5a00410050002d004e0035002e0031002d003800460053002d0033003700420043004300030043003
    mscorlib,版本=1.0.5000.0,文化=中性,PublicKeyToken=b77a5c561934e089,自定义=5a00410050002d004e0035002e0031002d0038004600440053002d003300370042004300360040000406004

项目数 = 2
于 2008-09-18T19:43:00.240 回答
0

在寻求帮助诊断编译问题时,发布有问题的源代码通常会有所帮助:)

这些错误实际上意味着指定的名称与另一个名称冲突,编译器无法解决这个问题。看起来确实有点奇怪。。

于 2008-08-18T16:22:15.370 回答
0

我也受到了打击,特别是 System.Data.SqlClient。尝试在项目管理器中取消选中命名空间并手动将它们包含在 .vb 文件中,就像使用 C# 一样:

导入 System.Data.SqlClient

于 2008-08-18T16:34:18.480 回答
0

取一个错误(如 ArrayList)并将类型替换为全限定名称(我不确定,但我猜这里:System.Collection.ArrayList)。如果错误消失了,你真的有一个解决冲突。如果不是,那就是另外一回事了。
如果所有解决方案在这些错误的情况下都“正常”,我建议清理你的项目。删除所有已编译的内容(dll、pdb 等),以及影子缓存的内容。也许它编译是因为它使用了旧版本的东西。

于 2008-08-18T16:34:52.973 回答
0

我知道这听起来很奇怪,但您是使用“构建”还是“重建”来构建解决方案?如果我遇到这样有趣的问题,解决方案的“全部重建”会有所帮助。

于 2008-08-18T18:20:48.327 回答
0

昨天我在 VS2005 ASP.NET 网站项目中得到了同样的结果:突然之间,由于之前的任何重大代码更改,在命名空间 'y' 中出现的负载 'x' 是模棱两可的,它们都源自非常基本的符号,例如 EventArgs,类型、DBNull 等

直接原因是双重引用的 mscorlib,正如我在 VS 的类视图中看到的那样。我相信,真正的原因是自动 Windows 更新迫使我在几分钟前重新启动机器。

尝试诸如建立一个全新的 ASP.NET 网站项目,将源文本复制粘贴到其上(在同一台机器上 - 没有帮助)或将项目移动到具有相同 VS2005 安装的第二台机器上(它有助于,项目正常工作)我几乎可以肯定我的代码没有问题,但我的 VS/.NET 配置。而且我非常不知道如何治愈它,因为除了这个之外,互联网上没有描述类似问题的痕迹。

于 2009-02-26T20:28:29.990 回答
0

重新安装.Net Framework 2.0

那应该解决它。之后,gacutil(从 v2.0 开始)将显示 1mscorlib而不是 0。

于 2009-02-26T20:37:26.990 回答