0

i created a little application (win forms) thats create a solution, adds a project and some files to the project. By clicking a button, the new solution should open by the installed vs2010 express. Thats works fine, everything is ok. My question, is there a way to open a specific file in the solution when the hole solution was loaded? For a better understanding, the user (of my application) creates a sln with 3 files (a.cs, b.cs and c.cs). He selects b.cs (in my application), and opens the sln. In the editor in vs, the preselected b.cs should be open.

I've tried to create a sou - file, but i think thats not the right way...

Is there a way to do this?! Thx and regards Sascha

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
Sascha
  • 1
  • 1
  • You are using the wrong tool. You can do these kind of things easily in Visual Studio, just not the Express edition. It has no support for add-ins. – Hans Passant Jan 27 '12 at 10:53

1 Answers1

2

Visual Studio remembers the files you had open when you last closed the solution, along with other things like breakpoints, by using the SUO file. You can check this with a simple experiment: close your solution with just a single file opened inside it (a.cs, for example), manually delete the SUO file (don't worry, VS recreates it if it doesn't exists) and when you open the solution again you'll see you won't have any file opened, and you'd lost any breakpoints you had.

So the obvious thing to do here would be to manipulate the SUO, storing on it the file selected by the user and then opening VS from your tool. The only thing I've found on the documentation is the IVsPersistSolutionOpts but I don't have any direct experience with it.

Also check this CodeProject article: while its main focus is to add a Tool Window to Visual Studio, it also uses IVsPersistSolutionOpts.

CMPerez
  • 905
  • 1
  • 10
  • 25
  • I know that the suo file is responsible for the opened file. The problem is, the sou file is a binary one... I can't believe that it should be so a huge problem to open a file from outside... but thx for the code project article!! – Sascha Jan 27 '12 at 10:13