.NET MissingMethodException 发生在数千台最终用户计算机中的一台上 - 有什么见解吗?

发布于 2024-07-25 23:34:03 字数 1904 浏览 10 评论 0原文

这个问题让我感到困惑,它影响了单个用户(据我所知),并且我们尚未重现...

  • 用户收到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

不必你懂 2024-08-01 23:34:04

听起来您正在使用一种方法,该方法是在 .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.

ま柒月 2024-08-01 23:34:04

鉴于该问题的罕见性,这很可能是该用户计算机上的软件环境损坏造成的。

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.

<逆流佳人身旁 2024-08-01 23:34:04

这是否有可能是 .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.

靑春怀旧 2024-08-01 23:34:04

问题机器上的操作系统是否与其他机器不同? 几年前我调试过一个类似的错误,我认为将其追溯到 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文