.NET MissingMethodException 发生在数千台最终用户计算机中的一台上 - 有什么见解吗?
这个问题让我感到困惑,它影响了单个用户(据我所知),并且我们尚未重现...
用户收到 MissingMethodException,我们的跟踪文件表明它是在我们创建新的实例后发生的一个组件,当我们调用一个Initialize/Setup方法准备让它工作时(示例中的InitializeWorkerByArgument)
错误指定的方法是一个接口方法,基类实现该方法,并从该方法派生类基类可以根据需要重写
用户拥有我们的最新版本应用程序
所有提供的代码都在单个程序集中提供
以下是该组件的一个非常精炼的版本:
class Widget : UserControl
{
public void DoSomething(string argument)
{
InitializeWorkerByArgument(argument);
this.Worker.DoWork();
}
private void InitializeWorkerByArgument(string argument)
{
switch (argument)
{
case "SomeArgument":
this.Worker = new SomeWidgetWorker();
break;
}
// The issue I'm tracking down would have occured during "new SomeWidgetWorker()"
// and would have resulted in a missing method exception stating that
// method "DoWork" could not be found.
this.Worker.DoWorkComplete += new EventHandler(Worker_DoWorkComplete);
}
private IWidgetWorker Worker
{
get;
set;
}
void Worker_DoWorkComplete(object sender, EventArgs e)
{
MessageBox.Show("All done");
}
}
interface IWidgetWorker
{
void DoWork();
event EventHandler DoWorkComplete;
}
abstract class BaseWorker : IWidgetWorker
{
virtual public void DoWork()
{
System.Threading.Thread.Sleep(1000);
RaiseDoWorkComplete(this, null);
}
internal void RaiseDoWorkComplete(object sender, EventArgs e)
{
if (DoWorkComplete != null)
{
DoWorkComplete(this, null);
}
}
public event EventHandler DoWorkComplete;
}
class SomeWidgetWorker : BaseWorker
{
public override void DoWork()
{
System.Threading.Thread.Sleep(2000);
RaiseDoWorkComplete(this, null);
}
}
This issue has me baffled, it's affecting a single user (to my knowledge) and hasn't been reproduced by us...
The user is receiving a MissingMethodException, our trace file indicates it's occuring after we create a new instance of a component, when we're calling an Initialize/Setup method in preparation to have it do work (InitializeWorkerByArgument in the example)
The Method specified by the error is an interface method, which a base class implements and classes derived from the base class can override as-needed
The user has the latest release of our application
All the provided code is shipped within a single assembly
Here's a very distilled version of the component:
class Widget : UserControl
{
public void DoSomething(string argument)
{
InitializeWorkerByArgument(argument);
this.Worker.DoWork();
}
private void InitializeWorkerByArgument(string argument)
{
switch (argument)
{
case "SomeArgument":
this.Worker = new SomeWidgetWorker();
break;
}
// The issue I'm tracking down would have occured during "new SomeWidgetWorker()"
// and would have resulted in a missing method exception stating that
// method "DoWork" could not be found.
this.Worker.DoWorkComplete += new EventHandler(Worker_DoWorkComplete);
}
private IWidgetWorker Worker
{
get;
set;
}
void Worker_DoWorkComplete(object sender, EventArgs e)
{
MessageBox.Show("All done");
}
}
interface IWidgetWorker
{
void DoWork();
event EventHandler DoWorkComplete;
}
abstract class BaseWorker : IWidgetWorker
{
virtual public void DoWork()
{
System.Threading.Thread.Sleep(1000);
RaiseDoWorkComplete(this, null);
}
internal void RaiseDoWorkComplete(object sender, EventArgs e)
{
if (DoWorkComplete != null)
{
DoWorkComplete(this, null);
}
}
public event EventHandler DoWorkComplete;
}
class SomeWidgetWorker : BaseWorker
{
public override void DoWork()
{
System.Threading.Thread.Sleep(2000);
RaiseDoWorkComplete(this, null);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您正在使用一种方法,该方法是在 .NET Framework 2.0 的 SP 中发布的。
我遇到了同样的问题,因为我使用了 手动重置事件。 我不得不将其替换为 WaitOne(int,bool)。
.NET Framework SP 2 中添加了方法 WaitOne(int),该方法在安装 .NET Framework 3.5 SP1 时应用。
在这种情况下,我建议阅读 MSDN。 “版本信息”告诉您哪个框架或服务包支持特定方法。
That sounds like you are using a method, that was release in a SP of the .NET Framework 2.0.
I had the same problem as i used the method WaitOne(int) of ManualResetEvent. I had to replace it with WaitOne(int,bool).
The method WaitOne(int) was added in .NET Framework SP 2, which is applied when you install .NET Framework 3.5 SP1.
In such a case, i recommend to read the MSDN. The "Version Information" tells you in which framework or service pack a specific method is supported.
鉴于该问题的罕见性,这很可能是该用户计算机上的软件环境损坏造成的。
Given the rarity of the problem, it seems likely that this is the result of a broken software environment on that one user's computer.
这是否有可能是 .NET Framework 依赖性问题,并且该用户没有所需的 .NET 版本? 只是一个想法。
Any chance this is a .NET Framework dependency issue and this user doesn't have the required .NET version? Just a thought.
问题机器上的操作系统是否与其他机器不同? 几年前我调试过一个类似的错误,我认为将其追溯到 .Net 类型解析领域的一种特定 Windows 风格上的奇怪行为。
Is the OS on the problem machine different to all of the others? I debugged a similar error years ago and I think I traced it to weird behavior on one particular flavour of Windows in the area of .Net type resolving.