views:

64

answers:

1

I created a Word 2007 add-in project in C# that works fine on my box and a fellow developer's box. When we try to deploy the software to a blank box though, Word crashes hard (no exception thrown) when we start up a background thread.

Here's the relevant code, in the Ribbon.cs file:

private void startThread()
{
    StreamWriter fout = new FileInfo("C:\\startThread.txt").CreateText();
    fout.WriteLine("startThread start");
    fout.Flush();
    try {
        ThreadStart job = new ThreadStart(this.waitForSignal);
        Thread thread = new Thread(job);
        thread.Start();
        fout.WriteLine("No Exceptions?");
    }
    catch
    {
        fout.WriteLine("caught something");
    }
    fout.WriteLine("startThread end");
    fout.Flush();
    fout.Close();
}
public void waitForSignal()
{
    StreamWriter fout = new FileInfo("C:\\waitForSignal.txt").CreateText();
    fout.WriteLine("entered waitForSignal");
    fout.Flush();
    fout.Close();
}

startThread() is called from the Ribbon's constructor. When run on my box, both files are created with all of the WriteLines except "caught something". When run on the other box, startThread.txt is created and all lines are output except "caught something" but waitForSignal.txt is never created and Microsoft's "there's been a problem, would you like to send an error message" box appears.

I think there is some security problem that's denying Word the ability to start new threads, but I can't figure out how I would change that.

Does anyone know if that is indeed the problem and how I would fix it? Or if you see something else that might be causing the problem?

A: 

Turns out that my Ribbon code required .NET 2.0 Service Pack 2 and the user's computer only had .NET 2.0 Service Pack 1 installed. Makes Microsoft sense that a service pack change on the same version would create incompatible code.

Ryan Ahearn