all groups > dotnet web services > march 2006 >
You're in the

dotnet web services

group:

Discovering the VS project from a SchemaImporterExtension


Discovering the VS project from a SchemaImporterExtension George
3/29/2006 12:06:02 PM
dotnet web services:
I am stuck here. Any help is greatly appreciated!

I am writing a SchemaImporterExtension for use with "Add Web Reference" in
Visual Studio. Ideally, I want to know within this extension the collection
of dlls that are referenced by the current project, so that I can resolve and
share all the types by reiterating through all the types. For this purpose I
need a way get the current project object model, or at least know the folder
Re: Discovering the VS project from a SchemaImporterExtension Josh Twist
3/30/2006 5:29:27 AM
Hi George,

I had a very similar idea but I believe this is difficult because the
SchemaImporterExtension is called form WSDL.exe (which is launched by
VS2005's Add Web Reference) and therefore isn't even in the same
process as the project.

I guess the next stage is to see if you can somehow talk to VS2005 but
I've just not had time to follow this through.

I'll be watching this post closely though :)

Josh
http://www.thejoyofcode.com/
RE: Discovering the VS project from a SchemaImporterExtension George
3/31/2006 6:45:01 AM
At last I made it work.

The method is to use COM service (ole32.dll) to iterate through all running
processes and look for a process with the name "VisualStudio.DTE.8.0" +
System.Diagnostics.Process.GetCurrentProcess().Id.ToString(), cast the object
to EnvDTE80.DTE2, then the Project object, say proj, is the first item in the
ActiveSolutionProjects collection. Moreover, by casting proj.Object to
VSProject, the list of references can easily be found.

Now come two more questions:

1) I would like to only generate the old style asynchronous methods
(begin<MethodName> and end<MethodName> methods) instead of the new style
asynchronous methods (<MethodName>async), how can I do that?

2) I want to replace the base class SoapHttpClientProtocol with a class
called MySoapHttpClientProtocol, how can I tell Visual Studio to use the
Re: Discovering the VS project from a SchemaImporterExtension Josh Twist
4/2/2006 7:18:52 AM
Congratulations George,

What happens if you have two instances of Visual Studio running? How do
you know you've found the right process?

In answer to your other two questions, I think you'll need to see what
other extensibility options WSDL.exe supports as it's responsible for
generating the proxy code.

Josh
http://www.thejoyofcode.com/
Re: Discovering the VS project from a SchemaImporterExtension Josh Twist
4/2/2006 7:22:29 AM
PS - Are you sure you need to use interop? Maybve you Could use .NET's
System.Diagnostics.Process.GetProcesses() or GetProcessByName()
methods?

Josh
http://www.thejoyofcode.com/
Re: Discovering the VS project from a SchemaImporterExtension George
4/3/2006 12:59:02 PM
Hi Josh,

The problem with Process methods is that they all return a Process object,
which can not be used to automate Visual Studio. Actually in my approach, I
do use the GetCurrentProcess().Id to identify the instance of relevence. What
I need is a EnvDTE80.DTE2 object, from which the VSProject can be accessed.

AddThis Social Bookmark Button