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



The information in this article applies to:

  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition

SYMPTOMS

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:
msenv!CVsUIHierarchyBaseWin::UpdateSelCtx+0xfa
msenv!CWinSelection::SelectItem+0x73
msenv!CVsUIHierarchyBaseWin::ExpandItem+0x19a
msats10!CHierNode::ExtExpand+0xc8
msats10!TSBaseFileViewNode::AddVirtualProjectWrapper+0x4d
msats10!TSBaseFileViewNode::AddVirtualProjectWrapper+0x93
msats10!TSProject::OpenChildren+0xce
msenv!CSolution::Open+0xdae
msenv!CVSolution::Open+0xa2

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.

Modification Type:MinorLast Reviewed:5/20/2005
Keywords:kbCompiler kbProgramming kbtshoot kbbug KB888325 kbAudDeveloper