NullReferenceException with Application.ProductName

D

DemonIT

Hi,

I am trying to set the status bar of my form to include the product
name and product version.

Here is my code:

Private Sub initStatusBar()
Dim sSBText as String = Application.ProductName & Space(3) &
"v" & Application.ProductVersion
sb.Text = sSBText
End Sub

When I run this I get:

An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.

I cannot understand why - you cannot create an instance of the
Application class and nor should you have to, right?

Any ideas?

Thanks,

James.

P.S - It's definately the Application bit that is wrong - because this
produced the same error:

Dim Fullname As String = Application.ProductVersion.ToString
MsgBox(Fullname)

Also, where in Visual Studio do I change the Product Name and
Version?
Thanks.
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed)-dot-uk.no-spam.invalid (DemonIT) scripsit:
I am trying to set the status bar of my form to include the product
name and product version.

Here is my code:

Private Sub initStatusBar()
Dim sSBText as String = Application.ProductName & Space(3) &
"v" & Application.ProductVersion
sb.Text = sSBText
End Sub

When I run this I get:

An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.

Are there any further infos on the exception?
I cannot understand why - you cannot create an instance of the
Application class and nor should you have to, right?

I don't understand why.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top