.NET MissingMethodException occuring on one of thousands of end-user machines -- any insight?

Posted by Yoooder on Stack Overflow See other posts from Stack Overflow or by Yoooder
Published on 2009-07-08T11:38:39Z Indexed on 2010/06/17 5:43 UTC
Read the original article Hit count: 256

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);
    }
}

© Stack Overflow or respective owner

Related posts about .NET

Related posts about exception