C#“未找到方法"运行时异常,不使用反射 [英] C# "Method not found" exception on runtime without usage of reflection

查看:59
本文介绍了C#“未找到方法"运行时异常,不使用反射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以上异常的问题.我有一个相对简单的结构,分为两个dll.

I have a problem with getting above exception. I have a relatively simple structure separate in two dll.

第一个包含具有基本实现的IEntityService IEntity.第二部分包含实际的实现以及接口.因此,有一个实现IEntityService和MachineService的IMachine服务,它们同时实现了IEntityService和EntityService.结果集合(实体加服务)也会发生类似情况.另外,服务(机器和结果)是局部类/接口,其中一个类是自动生成的.

First one contains a IEntityService, IEntity, with basic implementation. Second one contains the actual implementations as well as interfaces. so there is a IMachine service which implements IEntityService and MachineService which implements both IEntityService and EntityService. Similar situation happen for a Result collection( entity plus service). Additionally the service(Machine and result) are partial classes/interfaces where one of the class is auto generated.

现在在ResultMachine之一中,我正在尝试购买一台机器,如果它不存在,我将在创建它并保存.但是,当我尝试保存时,尝试从EntityService类访问保存方法时出现了找不到方法".但是,如果我将EntityService.Save方法包装在MachineService中,它将正常工作.

Now in one of the ResultMachine I am trying to get a machine and in a case it do not exists I am creating it and saving. However when I am trying to save I got the "Method not found" when trying to access a saving method from a EntityService class. However if I wrap EntityService.Save method in a MachineService it is working without any exception.

不需要代码.解决方法是重新链接参考.我误认为我的dll不在GAC中,而是与VS链接在一起.更重要的是,它不是强签名的,唯一的区别是版本号.

The code is not required. THe resolution was to re-link the reference. What was misleading for me that my dll is not in GAC, it is linked with VS. What is more it is not strongly signed, the only difference is version number.

推荐答案

我的第一个直觉是检查以确保程序集包含缺少方法的类.我想程序集可能不会立即更新?

My first instinct would be to check to make sure the assemblies contained the classes with the missing method. I suppose its possible that the assembly didn't get updated immediately?

这篇关于C#“未找到方法"运行时异常,不使用反射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆