BUG: You may receive a "COMException (0x80010105): The server threw an exception" error message in Visual Studio .NET 2003

BUG #: 25364 (Content Maintenance)
In Microsoft Visual Studio .NET 2003, if you automate your application to run out-of-process, you may receive a COM exception error message that is similar to the following from the Devenv.exe out-of-process component:
Unhandled Exception: System.ApplicationException: Failed ---> System.Runtime.Int

eropServices.COMException (0x80010105): The server threw an exception. at EnvDTE._Solution.Open(String FileName) at DTEAutomation.Class1.Main(String[] args) in c:\vs7play\enterprisetemplate\ dteautomation\class1.cs:line 45

--- End of inner exception stack trace --- at DTEAutomation.Class1.Main(String[] args) in c:\vs7play\enterprisetemplate\ dteautomation\class1.cs:line 80

Cause

This problem occurs because a cached pointer to the selected data is not valid. Then, the Enterprise Template Project is opened.

Workaround

To work around this problem, use one of the following methods.

Method 1

Open the MainWindow property as visible before you open the Enterprise Template Project. To do this, add the following code example before the solution.Open statement in your code.
solution.DTE.MainWindow.Activate();

Method 2

Hide the Solution Explorer window before you open the Enterprise Template Project. To do this, change the solution.Open statement to look similar to the following code example.
Window w = cls.DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer);
w.Visible=false;

solution.Open(solutionFileName);
w.Visible=true;

Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.

More Information

Call stack information

When this problem occurs, you may notice a call stack that is similar to the following:

Steps to reproduce the problem

  1. Start Visual Studio .NET 2003.
  2. Click File, point to New, and then click Project.
  3. In the New Project dialog box, click Other Projects, click Enterprise Template Projects, and then click Visual Basic Simple Distributed Application.
  4. Close the solution.
  5. Click File, point to New, and then click Project.
  6. In the New Project dialog box, click Visual C# Projects, and then click Windows Application.
  7. Add the following code to the Microsoft Windows Application project that you created in step 6.

    Note Replace the solutionFileName string with the path of the solution that you created in step 3.
    [STAThread]
    static void Main(string[] args)
    {
    const string DEFAULT_VISUAL_STUDIO_PROGID = "VisualStudio.Solution.7.1";

    string progID = DEFAULT_VISUAL_STUDIO_PROGID;

    Solution solution;
    try
    {
    Type t = Type.GetTypeFromProgID(progID);
    object obj = Activator.CreateInstance(t, true);
    Solution cls = (Solution)obj;
    string solutionFileName = @"C:\vs7play\enterprisetemplate\Project3\Project3.sln";

    solution = cls;
    solution.Open(solutionFileName);
    }
    }
    catch(Exception ex)
    {
    throw new ApplicationException(String.Format("Failed", progID), ex);
    }
    }
  8. Run the console application.
You receive the error message that is mentioned in the "Symptoms" section.
Propriedades

ID do Artigo: 888325 - Última Revisão: 13 de mai de 2008 - Revisão: 1

Comentários