Immediate Awkwardness

mafrosis

Well-known member
Joined
Jun 5, 2006
Messages
88
Location
UK
Programming Experience
5-10
Hey all,

Hopefully this is an easy answer for the person who knows it ;)

In the Form.Load of my small application, why is it the case that I can MsgBox the Application.ProductVersion and get a result, but then in the Immeadiate window I get an error??

VB.NET:
msgbox(Application.ProductVersion)
VB.NET:
?Application.ProductVersion
'ProductVersion' is not a member of 'MyApplication'.
Tanks all
mafro
 
VB.NET:
msgbox(Application.ProductVersion)
VB.NET:
?[B]Application[/B].ProductVersion
'ProductVersion' is not a member of [B]'[COLOR=red]My[/COLOR]Application'[/B].
Tanks all
mafro

I dont think the immediate window would ever deliver the second line as a response to the first line
 
I get the same error. (Express version if that differs)
 
I took a lok at it and found out why: It's due to an ambiguous reference..


When you write Application.XYZ you could be referring to either of:

Public NotInheritable Class System.Windows.Forms.Application (of which .ProductVersion is a Shared/static proeprty)
Friend ReadOnly Property Application as <your_vb_project_name>.My.MyApplication (which does not contain a member .ProductVersion)


The immediate window attempts to access the latter, whereas the main code accesses the former. All I can suggest is, be more specific:

VB.NET:
?Application.ProductVersion
'ProductVersion' is not a member of 'MyApplication'.
?My.Application.ProductVersion
'ProductVersion' is not a member of 'MyApplication'.
?Windows.Forms.Application.ProductVersion
"1.0.0.0"

Or use C#, which doesnt have the My. namespace :D
 
Back
Top