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 / Extensibility / May 2007

Tip: Looking for answers? Try searching our database.

Getting the System.Type of a CodeType or CodeTypeRef?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kenneth Baltrinic - 06 Apr 2007 12:55 GMT
I am writing a code generator in which I need get various information about
pre-existing types referenced in the current code body.  As long as the
types are defined in the current solution, that's not too hard.  I can find
a CodeElement for that type and go from there.  However, if the type is
external to the solution (lets say a .Net type like DataSet) then it seems I
can't get any member/type information about it other than its name from the
code model classes.  Is there a way, starting from a CodeTypeRef ( on
returned by CodeFunction.Type for example ) to get to a System.Type?
Mirko Matytschak - 09 May 2007 17:48 GMT
Hi Kenneth,

getting a System.Type means loading the assembly containing the type. In an
add-in you can iterate over all references of the project and load the
according assemblies. But the assemblies remain loaded as long as VS is
open. If one of the assemblies is a assembly of the same solution, the next
build would fail.

I think, the only way to get the information you wish is to launch an
external application (or a new app domain), which loads all referenced
assemblies and determines the information you wish to have. Collect the
names of the types you wish information for, write them in an input file,
launch the application. In the external app load the assemblies, get the
types and write the wished information in an output file. After returning
from the launched application your add-in reads the output file and uses the
information.

Regards,
Mirko

>I am writing a code generator in which I need get various information about
>pre-existing types referenced in the current code body.  As long as the
[quoted text clipped - 4 lines]
>the code model classes.  Is there a way, starting from a CodeTypeRef ( on
>returned by CodeFunction.Type for example ) to get to a System.Type?

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.