Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VS 2008 Add-in creating VCProject

$
0
0

Hi,

I'm trying to create an add-in that dynamically creates a VCProject.  Code below is from the exec function.  _VCEngine is a private member variable type VCProjectEngine of Connect class. 

VCProject p2;
if (_VCEngine == null) 
{ 
    _VCEngine = new VCProjectEngineObject(); 
} 
try 
{ 
    p2 = (VCProject)_VCEngine.CreateProject("test");
    p2.AddPlatform("Win32"); 
    p2.AddConfiguration("Debug"); 
    String mydocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); 
    p2.ProjectFile = mydocs + "\\test"; 
    p2.Save(); 
    _applicationObject.Solution.AddFromFile(p2.ProjectFile, false); 
} 
catch (Exception e) 
{ 
    System.Console.WriteLine(e.Source);
    System.Console.WriteLine(e.Message); 
}

This works fine on the first call to the add-in. If I delete the project file and try again, I always get the following exception in the output window.

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in JDECodeAssist.dll

The exception message caught in the code says "Cannot access data for the desired project since it is in a zombie state."  It occurs during the call to VCProject.Save().

I'm obviously new to this but tried the same strategy in VB and got the same result.  Interestingly, if I create a macro that does something similar I do not have any problems.  I'm wondering if I'm not doing something correctly with the VCProjectEngine. 

Thanks in advance,

Craig


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>