System.TypeLoadException

ぐ巨炮叔叔 提交于 2020-03-22 06:58:23

问题


I'm receiving the following error in my WPF application:

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 OnStartup override when calling:

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.


回答1:


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.

So in short it was a .dll mismatch in my MEF directory, so be sure to check for something like that.

Hope this helps someone!




回答2:


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.

Updating the packages in all the projects fixed the issue.



来源:https://stackoverflow.com/questions/15155312/system-typeloadexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!