添加一个可选的参数后system.missingMethodException而 [英] System.MissingMethodException after adding an optional parameter

查看:180
本文介绍了添加一个可选的参数后system.missingMethodException而的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到system.missingMethodException而错误后,我有一个可选的参数,在一个组件和调用它的其他组件没有被建立,因为它与老数量的参数调用它。


$ B在其中添加参数$ b

只有部分是建立一个部署补丁。 。调用组件是旧的,因为在它没有改变。



在调用组件来看,它提供了错误:



异常信息




异常类型:system.missingMethodException而消息:方法不是
发现:LabelURLs
IPSD。 BnB.Transaction.Postage.GetLabelURLs(System.String)。数据:
System.Collections.ListDictionaryInternal TargetSite:虚空
GenerateScanForm(的Int32,Int32)将HELPLINK:NULL来源:
BnBDispenseQueueProcess




据我所知道的新的参数是可选的,应该不会引发错误。
一件事调用组件(EXE)运行为Windows服务。



我们发现了一个非常有线解决办法,使其运行。通过一次删除更改的组件和运行调用组件,这将DLL说没有找到。这个地方在同一个DLL再次调用组件工作正常。)



我觉得我缺少.NET的一些内部


$ B。 $ b

让我知道,如果有更多的信息需要。


解决方案

只有成分,其中的参数加入是建立一个部署补丁。调用组件是旧的,因为在它没有任何改变。




的是它的变化,因为旧代码调用不再存在!方法




据我所知,应该不会引发错误作为新的参数可选的。




这不是一个执行时间的决定 - 这是一个的编译时间的决定。如果你有这样的方法:

 无效美孚(INT X,INT Y = 5)

和你这样称呼它:

 美孚(10); 



那么编译器有效地转换到这一点的呼叫:

 美孚(10,5); 



调用具有的完全的参数在二进制列表。如果你想从单参数版本的方式不影响二进制兼容性的多参数版本去,你就必须添加过载,而不是,如:

 无效美孚(INT X)
{
美孚(X,5);
}

无效美孚(INT X,int y)对
{

}

另外,你可以重新调用代码,并重新部署这一点。



我深表怀疑你的解决办法的。你确定你当你把DLL放回原处,你用的新的的版本(使用可选的参数),而不是旧版本?


取代了它

I am getting error of System.MissingMethodException after I have an optional parameter in one component and the other component which call it was not build as it call it with old number of parameters.

Only component in which parameter is added was build an deployed as patch. The calling component is old as there is no change in it.

When the calling component run it gives error :

Exception Information

Exception Type: System.MissingMethodException Message: Method not found: 'LabelURLs IPSD.BnB.Transaction.Postage.GetLabelURLs(System.String)'. Data: System.Collections.ListDictionaryInternal TargetSite: Void GenerateScanForm(Int32, Int32) HelpLink: NULL Source: BnBDispenseQueueProcess

As far as i know it should not raise an error as new parameter is optional. One more thing calling component(EXE) run as windows service.

we found an very wired workaround to make it run. By Removing the changed component once and run calling component which will say DLL not found. The place the same DLL again and calling component works fine:).

I think i am missing some internals of .net.

Let me know if more info needed.

解决方案

Only component in which parameter is added was build an deployed as patch. The calling component is old as there is no change in it.

There should be a change in it, because the old code calls a method which no longer exists!

As far as i know it should not raise an error as new parameter is optional.

That's not an execution-time decision - it's a compile-time decision. If you have a method like this:

void Foo(int x, int y = 5)

and you call it like this:

Foo(10);

then the compiler effectively converts that into a call of:

Foo(10, 5);

The call has the full argument list in the binary. If you want to go from the single-parameter version to the multi-parameter version in a way which doesn't affect binary compatibility, you'd have to add an overload instead, e.g.

void Foo(int x)
{
    Foo(x, 5);
}

void Foo(int x, int y)
{
    ...
}

Alternatively, you could rebuild the calling code and redeploy that as well.

I'm deeply suspicious of your workaround. Are you sure you when you put the DLL back in place you replaced it with the new version (with the optional parameter) rather than the old version?

这篇关于添加一个可选的参数后system.missingMethodException而的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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