这个问题让我感到困惑,它影响到单个用户(据我所知)并且我们没有复制......
用户正在接收 MissingMethodException,我们的跟踪文件表明它发生在我们创建组件的新实例之后,当我们调用 Initialize/Setup 方法准备让它工作时(示例中为 InitializeWorkerByArgument)
错误指定的Method是接口方法,基类实现,基类派生的类可以根据需要重写
用户拥有我们应用程序的最新版本
所有提供的代码都在一个程序集中发货
这是该组件的一个非常精炼的版本:
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);
}
}