PC Review


Reply
Thread Tools Rate Thread

How do I get the assembly name at compile time?

 
 
Dave
Guest
Posts: n/a
 
      30th Nov 2007
Surely it must be possible to access an assembly's name (ie the name of the
..exe or .dll file to which it will eventually compile) at compile time. All
the information is available within VS, but how do I get at it?

(Actually what I'd like to do is get the assembly name of a referenced
assembly, but I'm hoping that if I can do the first the second will be
trivial).

(NB- I know it can be acquired at runtime using reflection, that's not what
I'm asking.)
--
Dave
 
Reply With Quote
 
 
 
 
Peter Macej
Guest
Posts: n/a
 
      30th Nov 2007
The following macro shows project assembly name and then all referenced
assemblies names and paths:

Sub ShowAssemblies()
Dim project As EnvDTE.Project
project = DTE.Solution.Projects.Item(1)

Dim text As String

' get project assembly
text = "Project assembly: "
text &= project.Properties.Item("AssemblyName").Value.ToString
text &= vbCrLf & vbCrLf

' get references assemblies (will not work for web site projects)
Dim vsProject As VSLangProj.VSProject
Try
vsProject = DirectCast(project.Object, VSLangProj.VSProject)
Catch ex As Exception
End Try
If Not vsProject Is Nothing Then
Dim reference As VSLangProj.Reference
For Each reference In vsProject.References
text &= reference.Name & ": "
text &= reference.Path & vbCrLf
Next
End If

' show results
MessageBox.Show(text)
End Sub

Create this macro and run, see http://www.helixoft.com/blog/archives/6
if you don't know how.


--
Peter Macej
Helixoft - http://www.helixoft.com
VSdocman - Commenter and generator of class documentation for C#, VB
..NET and ASP .NET code
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing in-memory assembly on compile Andrus Microsoft C# .NET 1 5th May 2008 10:01 AM
using ilasm to compile assembly for CF2 Buthrakaur Microsoft Dot NET Compact Framework 3 23rd Aug 2006 07:52 AM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
How to compile a .aspx in a Assembly? Dexter Microsoft ASP .NET 1 26th Nov 2004 05:47 PM
compile satellite assembly programmatically Tom Regan Microsoft Dot NET Framework 2 21st Jun 2004 02:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:08 PM.