如何让 ASP.NET 网站使用正确的程序集(文件引用而不是路径/GAC)
我最近开始使用 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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打开 XML 格式的项目文件并找到相关参考。更改它,使其不具有强程序集名称,例如,
...更改为具有非限定名称和 HintPath 的名称,该 HintPath 指向代码库中已签入程序集的位置
(当然,我我只是在编造这些细节,没有 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,
...to one with an unqualified name and a HintPath that points to the spot in your codebase where the assembly has been checked in,
(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.
在您的 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.