当 gac 程序集移至全局 web.config 时,Visual Studio 2k8(和 2k10)无法编译 Web 应用程序

发布于 2024-08-28 11:46:30 字数 1635 浏览 5 评论 0原文

我有许多 ASP.NET 3.5 Web 应用程序,其中包含详细的应用程序级 web.config 文件,我希望精简这些文件并使其更具可读性。

Visual Studio 2010 刚刚发布,并且已经开始“清理”web.config 的各个部分 - 因此现在是我继续做好工作并在 web.config 文件的其他区域执行相同操作的最佳时机。

目前,我有几个第三方程序集都在 GAC 中注册,然后在每个应用程序级 Web.Config 中引用这些程序集,如下所示;

<configuration>
    <system.web>
        <compilation defaultLanguage="C#" debug="true">
            <assemblies>
                <add assembly="AjaxControlToolkit, Version=3.0.30512.20315, Culture=neutral, PublicKeyToken=28F01B0E84B6D53E"/>
                <add assembly="aspNetEmail, Version=3.5.2.0, Culture=neutral, PublicKeyToken=BC571E8DA1C1F543"/>
                <add assembly="aspNetDns, Version=3.0.0.0, Culture=neutral, PublicKeyToken=BC571E8DA1C1F543"/>
                <add assembly="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </assemblies>
        </compilation>
    </system.web>
</configuration>

我已将上述编译节点移动到位于 Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config 的全局 web.config 文件中 - 并且应用程序在 IIS7 下运行得很好,即应用程序没有找到任何问题这些 GAC 大会。

但是当我现在在 Visual Studio 2k8 或 2k10 中编译 (shift+ctrl+b) 我的 Web 应用程序时,我收到了熟悉的错误“无法找到类型或命名空间名称“aspNetDns”(是您缺少 using 指令或程序集引用吗?)”

我需要做什么才能让 Visual Studio 识别这些 GAC 库的位置?我尝试将它们复制到 windows\system32 中,但没有任何乐趣...

救命! :)

注意:我也尝试过使用 machine.config 但仍然没有运气

I have numerous ASP.NET 3.5 web applications with verbose application-level web.config files which I wish to slim down and make more readable.

Visual Studio 2010 has just arrived and has already started "cleaning up" various sections of the web.config - so now is a perfect time for me to continue the good work and do the same in other areas of the web.config file.

Currently I have several third party assemblies all happily registered in the GAC, these are then referenced in each application-level Web.Config see below;

<configuration>
    <system.web>
        <compilation defaultLanguage="C#" debug="true">
            <assemblies>
                <add assembly="AjaxControlToolkit, Version=3.0.30512.20315, Culture=neutral, PublicKeyToken=28F01B0E84B6D53E"/>
                <add assembly="aspNetEmail, Version=3.5.2.0, Culture=neutral, PublicKeyToken=BC571E8DA1C1F543"/>
                <add assembly="aspNetDns, Version=3.0.0.0, Culture=neutral, PublicKeyToken=BC571E8DA1C1F543"/>
                <add assembly="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </assemblies>
        </compilation>
    </system.web>
</configuration>

I have moved the above compilation-node into the global web.config file located at Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config - and the application runs just fine under IIS7 i.e. the application has no trouble finding these GAC'd assemblies.

however when I now compile (shift+ctrl+b) my web application in visual studio 2k8 or 2k10 I'm getting the familiar error "The type or namespace name 'aspNetDns' could not be found (are you missing a using directive or an assembly reference?)"

What do I have to do to get visual studio to recognise the whereabouts of these GAC'd libraries? I tried copying them into windows\system32 but no joy there...

help! :)

NB: I have also tried working with the machine.config but still no luck

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软甜啾 2024-09-04 11:46:30

解决了。

我需要编辑 x86 目录(以及 x64 版本)中的全局 web.config - x86 版本显然是 Visual Studio 在编译应用程序时查看的版本,而 IIS 正在查看全局 web.config 的 x64 版本运行应用程序时的 web.config。

Solved it.

I needed to edit the global web.config in the x86 directory (as well as the x64 version) - the x86 version is obviously the one Visual Studio was looking at whilst compiling the app, whereas IIS was looking at the x64 version of the global web.config when running the app.

流星番茄 2024-09-04 11:46:30

将程序集拖放到要重新编译的本地计算机上的 c:\windows\ assembly 中。

Drag / drop the assemblies to c:\windows\assembly on your local machine where you are recompiling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文