Application.ProductVersion gives NullReferenceException


G

Guest

I am working on upgrade a C# winform application from the 1.1 framework to
the 2.0 framework and experiencing a bizarre error.

When my converted aplication queries Application.ProductVersion, it throws a
System.NullReferenceException. This never happened in 1.1 and I don't think
it is supposed to work this way in 2.0.

The only solution my Google-Foo has found it make certain the main method is
named Main() not main(). This was not the problem.

How can I get the expected behavior out of Application.ProductVersion?

FWIW, my AssemblyInfo.CS contains:
[assembly : AssemblyVersion("2.2.0.0")]
which works just as expected in 1.1
 
Ad

Advertisements

G

Guest

This is very strange as the System.Windows.Forms.Application.ProductVersion
doesnt throw exceptions and is well coded to prevent them. Post you code
incase it is something about how you are calling or using it.

Ciaran O'Donnell
 
G

Guest

There isn't anything interesting about the code. It is a simple string
myVariable = "Blahblah " + Application.ProductVersion;

I tried to comment it out, and then a few lines later got a bizarre
exception about drag/drop on a line that set the Visible property of the form
to true.

Could it be possible that my 2.0 framework is corrupt somehow? Is there a
way the framework can be effectively removed and reinstalled?

Ciaran O''Donnell said:
This is very strange as the System.Windows.Forms.Application.ProductVersion
doesnt throw exceptions and is well coded to prevent them. Post you code
incase it is something about how you are calling or using it.

Ciaran O'Donnell

SvdSinner said:
I am working on upgrade a C# winform application from the 1.1 framework to
the 2.0 framework and experiencing a bizarre error.

When my converted aplication queries Application.ProductVersion, it throws a
System.NullReferenceException. This never happened in 1.1 and I don't think
it is supposed to work this way in 2.0.

The only solution my Google-Foo has found it make certain the main method is
named Main() not main(). This was not the problem.

How can I get the expected behavior out of Application.ProductVersion?

FWIW, my AssemblyInfo.CS contains:
[assembly : AssemblyVersion("2.2.0.0")]
which works just as expected in 1.1
 
G

Guest

You should be able to uninstall it in 'Add/Remove Programs' and then download
a new installer for it.
Sounds like a good be, even if just to remove the option from a list of
possibles

Ciaran O'Donnell

SvdSinner said:
There isn't anything interesting about the code. It is a simple string
myVariable = "Blahblah " + Application.ProductVersion;

I tried to comment it out, and then a few lines later got a bizarre
exception about drag/drop on a line that set the Visible property of the form
to true.

Could it be possible that my 2.0 framework is corrupt somehow? Is there a
way the framework can be effectively removed and reinstalled?

Ciaran O''Donnell said:
This is very strange as the System.Windows.Forms.Application.ProductVersion
doesnt throw exceptions and is well coded to prevent them. Post you code
incase it is something about how you are calling or using it.

Ciaran O'Donnell

SvdSinner said:
I am working on upgrade a C# winform application from the 1.1 framework to
the 2.0 framework and experiencing a bizarre error.

When my converted aplication queries Application.ProductVersion, it throws a
System.NullReferenceException. This never happened in 1.1 and I don't think
it is supposed to work this way in 2.0.

The only solution my Google-Foo has found it make certain the main method is
named Main() not main(). This was not the problem.

How can I get the expected behavior out of Application.ProductVersion?

FWIW, my AssemblyInfo.CS contains:
[assembly : AssemblyVersion("2.2.0.0")]
which works just as expected in 1.1
 
Ad

Advertisements

Joined
May 27, 2015
Messages
1
Reaction score
0
Most probably you have two application files, and your application is picking the incorrect one. Close your application in VS and then delete all the files in yourApp\bin\Debug and in yourApp\bin\Release. Open your application again in VS and rebuild your solution. This will force VS to create the bin files again.

Filantropo
 

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