首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.NET 2.0与.NET 4.0加载错误

.NET 2.0与.NET 4.0加载错误
EN

Stack Overflow用户
提问于 2010-06-11 03:07:05
回答 1查看 1.2K关注 0票数 4

我的类库是针对.NET 2.0编译的,每当我尝试将其作为2.0运行时的插件加载时,它都能正常工作。但是,如果主应用程序正在运行.NET 4.0运行时,只要需要访问资源,我就会得到一个异常:

代码语言:javascript
复制
Exception occurred during processing of command: Grasshopper
Plug-in = Grasshopper
Could not find file 'Grasshopper.resources'.

CALL STACK
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture)
at Grasshopper.My.Resources.Resources.get_GrasshopperBannerImage_Palette() in D:\dev\grasshopper\1.0\root\src\My Project\Resources.Designer.vb:line 1159
at Grasshopper.GUI.GH_Banner.ExplicitBanner_Load(Object sender, EventArgs e) in D:\dev\grasshopper\1.0\root\src\GH_Banner.vb:line 14
....

发生了什么?如何在所有.NET运行时加载我的项目?

编辑:问题是我写的一个AssemblyResolver,当被要求加载"Grasshopper.resources“时,它变得混乱了。似乎.NET 4.0处理资源加载的方式与早期的运行时有所不同?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-06-11 18:00:17

将资源程序集的测试添加到AssemblyResolver修复了这个问题,并允许我在.NET 2.0和4.0下运行这个类库:

代码语言:javascript
复制
private Assembly ResolveGrasshopper(object sender, ResolveEventArgs e)
{
  if (e.Name.Contains(".resources,")) { return null; }
  ....
}
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3017603

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档