如何让 ASP.NET 网站使用正确的程序集(文件引用而不是路径/GAC)

发布于 2024-11-08 19:19:43 字数 953 浏览 0 评论 0原文

我最近开始使用 Jenkins 来简化应用程序开发。我有一个 Asp.net 网站,我正在尝试使用它进行部署。

有关构建的详细信息:

  • 该项目是使用 Jenkins 从 Visual Source Safe 检索的。
  • 然后使用 msbuild 对其进行编译。
  • 构建完成后,将其部署到测试服务器。

编译运行良好,没有错误,没有警告。

当我将 Web 应用程序从 PrecompiledWeb 文件夹复制到测试服务器时,应用程序在执行某些操作时崩溃。我得到的异常如下:

异常类型:FileLoadException 
    异常消息:无法加载文件或程序集“Oracle.DataAccess, 
    版本 = 2.111.7.20,文化 = 中性,PublicKeyToken = 89b483f429c47342' 或 
    它的依赖项之一。找到的程序集的清单定义
    与装配参考不匹配。 
    (HRESULT 异常:0x80131040)

但是,如果我从网站的文件夹中复制 Web 应用程序,则一切正常。

注意:所有非 Microsoft 程序集都存储在解决方案级别名为 Assemblies 的文件夹中。项目中的所有引用都指向该程序集。

有没有办法找到冲突的来源,以便我可以使用 PrecompiledWeb 文件夹进行部署。

编辑: 我的项目中似乎引用了多个程序集,但我不知道如何只获取一个程序集。我检查了对象浏览器,选择了我的解决方案,我得到以下内容 对象浏览器中的两个程序集

看来 WebSite 项目是造成麻烦的一个(当我从解决方案中删除它时,仅右侧的程序集显示在对象浏览器中)。

I recently started using Jenkins to ease application Development. I have an Asp.net website that I am trying to deploy using it.

Details about the build:

  • The project is retreived from Visual Source Safe using Jenkins.
  • Is is then compiled using msbuild
  • Once it has been built, it is deployed to a test server.

The compile runs fine, no errors, no warnings.

When I copy the web application from the PrecompiledWeb folder to the test server, the application crashes when I perform certain operations. The exception I get is the following:

Exception type: FileLoadException 
    Exception message: Could not load file or assembly 'Oracle.DataAccess, 
    Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342' or 
    one of its dependencies. The located assembly's manifest definition
    does not match the assembly reference. 
    (Exception from HRESULT: 0x80131040)

However, if I copy the web application from the website's folder, everything works fine.

Note: All non-Microsoft assemblies are stored in a folder called Assemblies at the solution level. All references in the projects point to assemblies that foler.

Is there a way I can find where the conflict comes from so I can use the PrecompiledWeb folder for the deployment.

Edit:
It seems that I have more than one assembly referenced in my project, but I don't know how to get only one. I checked in the Object Browser, with My solution selected and I get the following
Both assemblies in object browser

It seems that the WebSite project is the one causing trouble (When I remove it from the solution, only the right assembly is shown in the Object Browser).

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

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

发布评论

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

评论(2

梦断已成空 2024-11-15 19:19:43

打开 XML 格式的项目文件并找到相关参考。更改它,使其不具有强程序集名称,例如,

<Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken={SOME-KEY}, processorArchitecture=MSIL" />

...更改为具有非限定名称和 HintPath 的名称,该 HintPath 指向代码库中已签入程序集的位置

<Reference Include="Oracle.DataAccess">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Oracle\Oracle.DataAccess.dll</HintPath>
</Reference>

(当然,我我只是在编造这些细节,没有 Oracle)

请注意,如果您当前的 Referenc 似乎已经正确设置了 HintPath,这并不重要,如果它具有强大的程序集名称,那么 GAC 中的任何内容都会具有优先。

Open the project file as XML and find the Reference in question. Change it so that it doesn't have a strong assembly name, for example,

<Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken={SOME-KEY}, processorArchitecture=MSIL" />

...to one with an unqualified name and a HintPath that points to the spot in your codebase where the assembly has been checked in,

<Reference Include="Oracle.DataAccess">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\Oracle\Oracle.DataAccess.dll</HintPath>
</Reference>

(of course, I'm just making up the details of these, not having Oracle)

Note that it doesn't matter if your current Referenc already seems to have the HintPath set up properly, if it has the strong assembly name then whatever is in the GAC will have precedence.

神经暖 2024-11-15 19:19:43

在您的 Visual Studio 项目中,当您在引用中选择该 DLL 并查看其属性时,Copy Local 是否设置为 true?否则,DLL 可能不会复制到输出文件夹。

In your Visual Studio project, when you select at that DLL in References and look at its properties, is Copy Local set to true? If not the DLL might not be copied over to the output folder.

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