Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / October 2004

Tip: Looking for answers? Try searching our database.

VSProject Cast files - more information

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan - 14 Oct 2004 14:33 GMT
Hi all -
I posted a message here yesterday about a cast from EnvDTE.Project to
VSLangProj.VSProject failing. I now have a reproducible snippet of code (see
below). The thing is, this only fails on my Windows XP laptop - on two
different Win 2000 machine it runs fine. If similar code is called from an
add-in on the Win XP machine, everything runs fine. I'm suspecting it has
something to do with the way I'm creating the DTE instance, but can't be
sure - any idea?

TIA -
Dan

Dim oType As System.Type
Dim oDTE As EnvDTE.DTE

'Get a type for the DTE object

oType = System.Type.GetTypeFromProgID("VisualStudio.DTE.7.1")

'Create it and cast

Dim oObj As Object = System.Activator.CreateInstance(oType, True)

oDTE = CType(oObj, EnvDTE.DTE)

'Open any solution with at least one project

Call oDTE.ExecuteCommand("File.OpenSolution", """PLACE ANY FULL SOLUTION
PATH HERE""")

'Find the first project in the solution and attempt to cast to VSProject

Dim oProject As EnvDTE.Project = oDTE.Solution.Item(1)

Dim oVSProject As VSLangProj.VSProject

Try

oVSProject = oProject.Object

'The cast worked, prove it.

Call MsgBox("Cast succeeded. Project has " & oVSProject.References.Count & "
references.")

Catch ex As Exception

Call MsgBox("Error: " & ex.Message)

End Try

oDTE.Quit()
Carlos J. Quintero [MVP] - 14 Oct 2004 14:57 GMT
Ideas:

- Try using "VisualStudio.DTE.7" (VS.NET 2002), just for testing.

- Compare the versions of the following DLLs:

EnvDTE.dll (C:\WINNT\Microsoft.NET\Framework\v1.xxxx)
VSLangProj.dll (C:\Archivos de programa\Microsoft Visual Studio
.NET\Common7\IDE\PublicAssemblies)

in both machines.

Signature

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com

> Hi all -
> I posted a message here yesterday about a cast from EnvDTE.Project to
[quoted text clipped - 48 lines]
>
> oDTE.Quit()
Dan - 14 Oct 2004 19:50 GMT
Carlos -
Thanks for the response.

The versions of both dlls is 7.0.9466.0 on both machines.

I don't have VS 2002 installed on either machine. Why did you suggest
checking it against VS 2002?

Thanks -
Dan

> Ideas:
>
[quoted text clipped - 62 lines]
> >
> > oDTE.Quit()
Carlos J. Quintero [MVP] - 15 Oct 2004 10:06 GMT
Just for seeing if IDE version makes a difference...

Signature

Carlos J. Quintero (Visual Developer - .NET MVP)

The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com

> Carlos -
> Thanks for the response.
[quoted text clipped - 6 lines]
> Thanks -
> Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.