C#:无法加载从装配类型

编程入门 行业动态 更新时间:2024-10-24 20:19:37
本文介绍了C#:无法加载从装配类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

添加Lucene和Lucene的Contrib一个C#MVC3后,我得到下面的第一个成功运行后的信息。收到此错误后,我需要彻底清除C:\\用户\\我\\应用程序数据\\本地\\ TEMP \\临时ASP.NET文件之前,我可以再次运行该项目

After adding Lucene and Lucene Contrib to a C# MVC3, I get the message below after the first successful run. After receiving this error, I need to completely wipe C:\Users\Me\AppData\Local\Temp\Temporary ASP.NET Files before I can run the project again.

我试着删除了Lucene手动文件(包括在我的项目引用),并重新安装它们 - 无论用的NuGet和手动 - 但它总是相同的情况;该项目已被运行一次后,我开始越来越以下错误:

I've tried removing the Lucene files manually (including references in my project), and reinstalling them - both with NuGet and manually - but it's always the same situation; after the project has been run once, I start getting the following errors:

注:Contrib.Regex是Lucene的Contrib的一部分

Note: Contrib.Regex is part of Lucene Contrib.

Server Error in '/' Application. Could not load types from assembly Contrib.Regex, Version=2.9.4.0, Culture=neutral, PublicKeyToken=85089178b9ac3181, errors: Exception: System.IO.FileLoadException: Could not load file or assembly 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181' === Pre-bind state information === LOG: User = rcw7\Me LOG: DisplayName = Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181 (Fully-specified) LOG: Appbase = file:///C:/Development/Projects/Foobar/Foobar/ LOG: Initial PrivatePath = C:\Development\Projects\Foobar\Foobar\bin Calling assembly : Contrib.Regex, Version=2.9.4.0, Culture=neutral, PublicKeyToken=85089178b9ac3181. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Development\Projects\Foobar\Foobar\web.config LOG: Using host configuration file: C:\Users\Me\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181 LOG: Attempting download of new URL file:///C:/Users/Me/AppData/Local/Temp/Temporary ASP.NET Files/root/e9b4cfa4/edfa73f8/Lucene.Net.DLL. WRN: Comparing the assembly name resulted in the mismatch: Revision Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. Exception: System.IO.FileLoadException: Could not load file or assembly 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181'

在这里全部输出: pastebin/Vbu4VK7B

起初我以为这是地方对我的发展环境问题,但重建和复制项目到我们的服务器后,我得到了同样的错误。

Initially I thought this was a problem local to my development environment, but after rebuilding and copying the project to our server, I get the same errors.

任何建议,如何克服呢? : - )

Any suggestions as how to overcome this? :-)

推荐答案

事实证明,该DLL地狱并没有在配置和编译库我自己插手造成的。它实际上是造成我的新下载Lucene.NET和版本有些过时版本检查捆绑,这反过来用一把umbraco 5.

As it turns out, the DLL hell wasn't caused by my own meddling in configurations and compiled libraries. It was in fact caused by a collision between my newly downloaded version of Lucene.NET and a somewhat dated version bundled with Examine, which in turn was bundled with Umbraco 5.

显然不合时宜,捆绑Lucene.NET结束了在阴影缓存(临时ASP.NET文件),所以下编译或IIS重启后,执行将打破。清除缓存阴影将允许一种成功执行。

Apparently the outdated, bundled Lucene.NET ended up in the shadow cache (Temporary ASP.NET Files), so after the next compile or IIS restart, execution would break. Clearing the shadow cache would allow for one success execution.

奇怪的是,我无法在调试输出暗示Lucene.NET的过期版本的任何地方发现任何引用,无论是与目录路径或版本号。问题是通过比较Lucene.NET和影像复制版本我打算使用的版本文件大小斑点。他们了,所以我做了一个Lucene.NET.dll搜索和发现了一把umbraco树一个与捆绑的检查(下\\ App_Plugins \\检查)

The weird thing was, that I was unable to find any reference anywhere in the debug output that hinted to the outdated version of Lucene.NET, either with a directory path or version number. The problem was spotted by comparing the file sizes of the shadow copied version of Lucene.NET and the version I intended to use. They were off, so I did a search for Lucene.NET.dll and found the one bundled with Examine in the Umbraco tree (under \App_Plugins\Examine)

快速的解决方案是简单地压缩了检查插件,所以一把umbraco不会看到它。这使我没有检查插件,但我不使用也无妨。

The fast solution was to simply zip the Examine plugin, so Umbraco wouldn't see it. That leaves me without the Examine plugin, but I wasn't using it anyway.

的右键的解决方案很可能会告诉它应该忽略Lucene.NET的previous版本的应用程序,但我还没有与任何运气至今。这是我加入到web.config中:

The right solution would probably be to tell the app that it should ignore previous versions of Lucene.NET, but I haven't had any luck with that so far. This is what I added to web.config:

<dependentAssembly> <assemblyIdentity name="Lucene.Net" publicKeyToken="85089178b9ac3181" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.9.4.1" newVersion="2.9.4.1" /> </dependentAssembly>

这似乎没有任何效果,而过时的版本依然在阴影缓存中结束了。我在这里提出这个问题:怎样使一把umbraco 5忽略捆绑(有检查)Lucene.NET

This didn't seem to have any effect, and the outdated version still ended up in the shadow cache. I've moved this question here: How do I make Umbraco 5 ignore the bundled (with Examine) Lucene.NET

感谢您的帮助和建议 - 这我指出了正确的方向! : - )

Thanks for your help and suggestions - it pointed me in the right direction! :-)

更多推荐

C#:无法加载从装配类型

本文发布于:2023-11-13 10:39:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584157.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   类型

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!