Click here to Skip to main content
15,895,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

i want to manipulate a C++ VCProject with C#-Code. Especially, i want to add a project reference. Every attempt to add a project reference with AddProjectReference() leads to an exception. (System.InvalidCastException because the desired data is in a zombie state)

Has anybody an idea what i do wrong?

Thanks in advance.


MSIL
VCProjectEngine vcProjectEngine = new VCProjectEngineObjectClass();
VCProject project1 = (VCProject)vcProjectEngine.LoadProject(@"C:\test1\test1.vcproj");
VCProject project2 = (VCProject)vcProjectEngine.LoadProject(@"C:\test1\test2.vcproj");


project1.AddProjectReference(project2);
Posted
Updated 15-Jan-11 23:33pm
v2

1 solution

Some interesting thing I found :
Do not instantiate VCProjectEngineObjectClass. Instantiate VCProjectEngineObject instead[^]

Maybe it helps.

Cheers
 
Share this answer
 
Comments
Espen Harlinn 16-Jan-11 5:58am    
5+ Should help :)
jay_85_ush 16-Jan-11 6:08am    
Thank you for your answer. But it is the same behavior with VCProjectEngineObject...
Estys 16-Jan-11 6:30am    
Can you manually add the project reference? Or does that fail as well.
jay_85_ush 16-Jan-11 9:27am    
Manually, it is possible to add a project reference. There is als a method called "CanAddProjectReference" and this method returns always false. But i don't know why....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900