|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Application.ProductVersion gives NullReferenceExceptionI 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 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 Show quote "SvdSinner" wrote: > 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 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? Show quote "Ciaran O''Donnell" wrote: > 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" wrote: > > > 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 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 Show quote "SvdSinner" wrote: > 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" wrote: > > > 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" wrote: > > > > > 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 |
|||||||||||||||||||||||