Project setting via code and EnvDTE

S

Sharon

Hello Gurus,
Hope you can help me…

I have s VS2005 solution with several C# projects.
I want to manipulate the projects to add a snk key file and to set the
projects to sign it using that key.

I’m trying to write a utility project in C# to change the project setting
for that purpose as follow:

using EnvDTE;
using EnvDTE80;
using VSLangProj80;

EnvDTE80.DTE2 dte;
dte = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE");
string str = dte.Solution.FullName;
Projects projects = dte.Solution.Projects;
VSLangProj80.VSProject2 vsPrj;
foreach( Project proj in projects )
{
vsPrj = (VSLangProj80.VSProject2)proj.Object;
Project prj = vsPrj.Project;

// Now I want to do the sign setting for the project.
}

The problem is that the line with VSLangProj80.VSProject2 causes en error as
follow:

System.IO.FileNotFoundException - "Could not load file or assembly 'EnvDTE,
Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified."

I don’t have this EnvDTE version and I could not find it to download.
I do have the newer versions.

How can I fix this?

Some more coding questions:
(1) How can I load the Solution object with a specific solution file of my
choosing?
(2) Having the VSProject2, how do I set it to sign with a specific snk key
file?

______
Thanks
Sharon
 
P

Peter Macej

(1) How can I load the Solution object with a specific solution file of my
choosing?

dte.Solution.Open(solutionPath)

This may take few seconds or even minutes, depending on solution size.
This command doesn't wait until solution is loaded. So you must check
(in cycle/timer) two things:
1. dte.Solution.isOpen must be true
2. dte.Solution.Projects.Count >=0 //this throws exception if the
solution is not loaded yet

I don't remember details but checking only one of the two didn't work
sometimes. So it's better to check both.

You can get better response to your questions in the following forums:
microsoft.public.vstudio.extensibility
and especially
http://social.msdn.microsoft.com/Forums/en-US/vsx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top