Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I need to detect which version of Visual studio is running my project when it is running through IDE , By using that I want to find out the path of visual studio in MyDocuments like:
C:\Users\xxx\Documents\Visual Studio 2012


Is there any C# method that can help me using VS2012?


Thanks in advance
Posted
Comments
Joezer BH 1-Sep-13 9:42am    
What do you mean which VS??? :confused:
Do you mean which .NET Framework is was compiled for?
albert sh 1-Sep-13 9:52am    
Thanks for consideration, I meant Visual studio 2012, no i don't need it when running from command line, but from IDE
Sergey Alexandrovich Kryukov 1-Sep-13 11:25am    
Why?
—SA
albert sh 1-Sep-13 11:31am    
@Sergey, I have developed a control that it will be used through IDE, I used dte.Edition but I get error :"Call was rejected with the callee ( exception from HRResult :.... ) most of the times.
All I want to do is to find out the path pointing to visual studio in my document of the developer who is running the control

If your project is a Visual Studio extension, you can use DTE.Edition.

If not, there is no way for your code to determine, nor should it really care about, which version of the Visual Studio debugger is attached to your code.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 1-Sep-13 11:25am    
Sure, a 5.
—SA
albert sh 1-Sep-13 11:36am    
@Dave, Thanks for your comment, I need it as I need it in my control, but most of the times I get error : "Call was rejected with the callee ( exception from HRResult :.... ) .
Dave Kreskowiak 1-Sep-13 13:14pm    
We've been fishing around trying to get you to tell us what this project is and why you need this. You're not listening.

Is your project a Visual Studio extension? Yes or No.
albert sh 1-Sep-13 21:32pm    
@Dave, Sorry I was out for a while, as I told above, its an extension.
I am using Visual studio 2012 pro.
Dave Kreskowiak 1-Sep-13 21:58pm    
OK, that's odd because usually this problem shows up from a multi-threaded out-of-proc application (external applications) making calls into Visual Studio before the COM interface is able to handle the call. An extention runs in-proc (inside Visual Studio), and normally doesn't suffer from this problem.

I think we'd need to see the code to figure this one out.
This property of the Application Class will return the Visual Studio path wherever it is on the PC.
Application.StartupPath
On my PC, this returns:
C:\Users\<MyUserName>\Documents\Visual Studio 2012\Projects\<MySolutionName>\<MyProjectName>\bin

You can extract the path to Visual Studio from the returned value. This works whether or not the default installation path was overridden or not.
 
Share this answer
 
v2
Comments
albert sh 1-Sep-13 21:36pm    
Thanks for your comment,
your solution is useful to understand the location of my solution but I need to detect the version of visual studio that the other developers are using while using my control.

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



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