Ted Palmer
asked on
MyString = Project Properties >> Application >> Assembly Information >> GUID ? How do I do this?
I will comment on the "Code" after I Submit the question so that I can make reference to line numbers.
EE Experts:
My development Environment is VS2008 .NET running under XP SP3.
My question is that from the 2 images and source code I have uploaded you can see how the values in the property sheet for the project properties >> Application Tab >> Assembly Information button are displayed in the About box which came from "Common Items" in the list of Windows Forms that appear when I right click on the Project then click on Add >> Windows Form. This all comes standard with the VS2008 IDE Visual Basic Solution. Nothing new and exotic going on here. When I place my insertion cursor after the "Info." in "My.Application.Info.Copyr ight" and delete a character so that the Intellisence will open a pop-up pick list, the pick list has nothing that I can use to get to the value of the GUID property. That is my question. How can I get to the value of the property GUID?
AssemblyInformation.bmp
EE Experts:
My development Environment is VS2008 .NET running under XP SP3.
My question is that from the 2 images and source code I have uploaded you can see how the values in the property sheet for the project properties >> Application Tab >> Assembly Information button are displayed in the About box which came from "Common Items" in the list of Windows Forms that appear when I right click on the Project then click on Add >> Windows Form. This all comes standard with the VS2008 IDE Visual Basic Solution. Nothing new and exotic going on here. When I place my insertion cursor after the "Info." in "My.Application.Info.Copyr
Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set the title of the form.
Dim ApplicationTitle As String
If My.Application.Info.Title <> "" Then
ApplicationTitle = My.Application.Info.Title
Else
ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
Me.Text = String.Format("About {0}", ApplicationTitle)
' Initialize all of the text displayed on the About Box.
' TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).
Me.LabelProductName.Text = My.Application.Info.ProductName
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
Me.LabelCopyright.Text = My.Application.Info.Copyright
Me.LabelCompanyName.Text = My.Application.Info.CompanyName
Me.TextBoxDescription.Text = My.Application.Info.Description
End Sub
AboutAutoSubrogate-1.bmpAssemblyInformation.bmp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this should work -
import System.Reflection assembly
Dim assembly as Assembly = Assembly.GetExecutingAssem bly()
Dim sGuid as String
sGuid = (assembly.GetType().GUID.T oString())
import System.Reflection assembly
Dim assembly as Assembly = Assembly.GetExecutingAssem
Dim sGuid as String
sGuid = (assembly.GetType().GUID.T
What about:
my.Application.Info.GetTyp e.GUID.ToS tring
my.Application.Info.GetTyp
ASKER
dbraunschweig's,
Congratulations you got it.
SameerJagdale you almost got it too, but your solution yielded a GUID that was not the one I was looking for. Please see the attached image files. I don't know for sure where the GUID your solution retrieved came from exactly. My educated guess is that every visual object or at least Windows Form visual objects has a GUID, and your solution retrieved the GUID of the Windows Form that was being displayed at the time that your code executed. But I was looking for the GUID of the "Project" object that was running. I reread my question, and I am sure that I worded my question to clearly indicate that is what I was looking for. The screen shot of the property sheet also showed that.
hnase, thank you for your suggestion, but I already tried that and got a syntax error.
dbraunschweig, I had to modify your code a little bit to get it to work, but I am absolutely OK with that. The "Attributes.Count" in the predicate of your IF statement gave me a syntax error that said "Count" was not a member of "System.Array". You can see the change that I made in the code snippet I uploaded. I see by your profile that you are very new to Experts-Exchange. This is a REALLY GOOD start. This was not an easy question. SameerJagdale's profile shows that he/she is really a very good "Expert", and he/she didn't quit hit the right bull's eye.
I have been reading about "Reflection", but I don't understand it well enough to use it successfully -- obviously! The solution offered by dbraunschweig and SameerJagdale will go a long way toward helping me understand "Reflection" well enough to use it. Thank you both very much.
Ted Palmer
dbraunschweig-sGUID.bmp
Congratulations you got it.
SameerJagdale you almost got it too, but your solution yielded a GUID that was not the one I was looking for. Please see the attached image files. I don't know for sure where the GUID your solution retrieved came from exactly. My educated guess is that every visual object or at least Windows Form visual objects has a GUID, and your solution retrieved the GUID of the Windows Form that was being displayed at the time that your code executed. But I was looking for the GUID of the "Project" object that was running. I reread my question, and I am sure that I worded my question to clearly indicate that is what I was looking for. The screen shot of the property sheet also showed that.
hnase, thank you for your suggestion, but I already tried that and got a syntax error.
dbraunschweig, I had to modify your code a little bit to get it to work, but I am absolutely OK with that. The "Attributes.Count" in the predicate of your IF statement gave me a syntax error that said "Count" was not a member of "System.Array". You can see the change that I made in the code snippet I uploaded. I see by your profile that you are very new to Experts-Exchange. This is a REALLY GOOD start. This was not an easy question. SameerJagdale's profile shows that he/she is really a very good "Expert", and he/she didn't quit hit the right bull's eye.
I have been reading about "Reflection", but I don't understand it well enough to use it successfully -- obviously! The solution offered by dbraunschweig and SameerJagdale will go a long way toward helping me understand "Reflection" well enough to use it. Thank you both very much.
Ted Palmer
Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set the title of the form.
Dim ApplicationTitle As String
'Dim assembly As Assembly = assembly.GetExecutingAssembly()
Dim strGuid As String
'strGuid = (assembly.GetType().GUID.ToString())
strGuid = GetGUID()
'Debug Code -- Save 2010-04-05 by Ted Palmer
MessageBox.Show("Value strGuid: " & strGuid, _
"Subrogation Debug Message:", MessageBoxButtons.OK, MessageBoxIcon.Stop)
If My.Application.Info.Title <> "" Then
ApplicationTitle = My.Application.Info.Title
Else
ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
End If
Me.Text = String.Format("About {0}", ApplicationTitle)
' Initialize all of the text displayed on the About Box.
' TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).
Me.LabelProductName.Text = My.Application.Info.ProductName
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
Me.LabelCopyright.Text = My.Application.Info.Copyright
Me.LabelCompanyName.Text = My.Application.Info.CompanyName
Me.TextBoxDescription.Text = My.Application.Info.Description
End Sub 'AboutBox1_Load
Private Function GetGUID() As String
Dim Assembly As System.Reflection.Assembly
Dim Attributes As Object()
Assembly = System.Reflection.Assembly.GetExecutingAssembly
Attributes = Assembly.GetCustomAttributes(GetType(System.Runtime.InteropServices.GuidAttribute), False)
'If Attributes.Count > 0 Then
If Not IsNothing(Attributes) Then
Return DirectCast(Attributes(0), System.Runtime.InteropServices.GuidAttribute).Value.ToString
Else
Return ""
End If
End Function 'GetGUID()
SameerJagdale-sGUID.bmpdbraunschweig-sGUID.bmp
ASKER
THANK YOU..!!
Your are very GOOD! I can tell.
Ted Palmer
Your are very GOOD! I can tell.
Ted Palmer
ASKER