Question

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);
    }
}
Was it helpful?

Solution

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.

OTHER TIPS

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.

Any chance this is a .NET Framework dependency issue and this user doesn't have the required .NET version? Just a thought.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top