wpf System.TypeLoadException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15155312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
System.TypeLoadException
提问by Chrisjan Lodewyks
I'm receiving the following error in my WPF application:
我在 WPF 应用程序中收到以下错误:
Declaration referenced in a method implementation cannot be a final method.
And the only thing I have found states that the problem is that a non-virtual method is being overridden, but I checked and could not find any in my object.
我发现的唯一一件事表明问题是非虚拟方法被覆盖,但我检查并在我的对象中找不到任何方法。
The error is not thrown when compiling but only when I debug.
编译时不会抛出错误,而只会在我调试时抛出错误。
Does anyone have a suggestion that I might try?
有没有人有我可以尝试的建议?
-- UPDATE
- 更新
I get the error in my App.Xaml.cs OnStartupoverride when calling:
OnStartup调用时,我在 App.Xaml.cs覆盖中收到错误:
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(new DirectoryCatalog(localDir));
_container = new CompositionContainer(catalog);
On the _container I receive 15 LoaderException after upgrading to CSLA 4.5.10.
在 _container 上,我在升级到 CSLA 4.5.10 后收到 15 LoaderException。
回答by Chrisjan Lodewyks
Okay I have found my issue. I hope that posting it here might help someone else find the issue that I have been searching for so long.
好的,我找到了我的问题。我希望在这里发布它可以帮助其他人找到我一直在寻找的问题。
In the code I have posted above the localDir points to a directory on my local machine where the projects are built to and then fetched with the MEF. The problem for me here was that there was a .dll to a different project that was still referencing an old version of CSLA and there Save(), was still being overridden although it is not allowed annymore.
在我上面发布的代码中,localDir 指向我本地机器上的一个目录,项目在该目录中构建,然后使用 MEF 获取。对我来说,这里的问题是,另一个项目的 .dll 仍然引用旧版本的 CSLA Save(),并且仍然被覆盖,尽管它是不允许的。
So in short it was a .dll mismatch in my MEF directory, so be sure to check for something like that.
所以简而言之,它是我的 MEF 目录中的 .dll 不匹配,所以一定要检查类似的东西。
Hope this helps someone!
希望这对某人有帮助!
回答by Fernando Moreira
This happened to me as well, I was running my tests and was getting the same error message.
这也发生在我身上,我正在运行测试并收到相同的错误消息。
The problem was that I had an updated nuget package in one of the projects and in the Test project that nuget package was outdated and therefor generating this issue.
问题是我在其中一个项目和测试项目中有一个更新的 nuget 包,该 nuget 包已经过时,因此产生了这个问题。
Updating the packages in all the projects fixed the issue.
更新所有项目中的包解决了这个问题。

