473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Program Version Number

We are using c# windows forms and just trying to get started with .net. I
want to do something that should be easy but I can't find any way to make it
work. We are using Click Once to publish to a network drive and I need to be
able to check if a program is the current version. Because the users can
choose to not download the latest version this may be a problem. I just want
to show what version they are running.

I found some code that gave me:

private void FrmMain_Load(object sender, EventArgs e)
{
FileVersionInfo fvi =
FileVersionInfo.GetVersionInfo(Application.Executa blePath);
string version = fvi.FileVersion.ToString();
MessageBox.Show(version);
}

I am not sure if this will give me what I need. And it also gets an error I
don't understand. Why would gettting the version number be a security
exception?

System.Security.SecurityException was unhandled
Message="Request failed."
Source="AfterSchool1"
Feb 1 '07 #1
3 12876
Hi,
"Bill Cart" <bc***@RemoveThis.lifecarealliance.orgwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
| We are using c# windows forms and just trying to get started with .net. I
| want to do something that should be easy but I can't find any way to make
it
| work. We are using Click Once to publish to a network drive and I need to
be
| able to check if a program is the current version. Because the users can
| choose to not download the latest version this may be a problem. I just
want
| to show what version they are running.

Try:
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version.ToString();--Ignacio Machinmachin AT laceupsolutions com

Feb 1 '07 #2
For ClickOnce, that won't give the current version number... instead (from a
post by Andrej Tozon):

if (System.Deployment.Application.ApplicationDeployme nt.IsNetworkDeployed)
{
Version version =
System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment.CurrentVersion;
string versionString = version.ToString();
}

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi,
"Bill Cart" <bc***@RemoveThis.lifecarealliance.orgwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
| We are using c# windows forms and just trying to get started with .net.
I
| want to do something that should be easy but I can't find any way to
make
it
| work. We are using Click Once to publish to a network drive and I need
to
be
| able to check if a program is the current version. Because the users can
| choose to not download the latest version this may be a problem. I just
want
| to show what version they are running.

Try:
System.Reflection.Assembly.GetExecutingAssembly(). GetName().Version.ToString();--Ignacio
Machinmachin AT laceupsolutions com

Feb 1 '07 #3
I tried the System.Deployment method
System.Deployment.Application.ApplicationDeploymen t ad1 =
System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment;
System.Windows.Forms.MessageBox.Show(ad1.CurrentVe rsion.ToString());

but when I test it I get the following error:

System.Deployment.Application.InvalidDeploymentExc eption was unhandled
Message="Application is not installed."
Source="System.Deployment"

I just found out the it only does this in the debuger so I guess that makes
sense, it really is not deployed yet.

"Ginger Estherskip" <ba****@127.0.0.1wrote in message
news:Oh*************@TK2MSFTNGP02.phx.gbl...
For ClickOnce, that won't give the current version number... instead (from
a post by Andrej Tozon):

if (System.Deployment.Application.ApplicationDeployme nt.IsNetworkDeployed)
{
Version version =
System.Deployment.Application.ApplicationDeploymen t.CurrentDeployment.CurrentVersion;
string versionString = version.ToString();
}

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi,
"Bill Cart" <bc***@RemoveThis.lifecarealliance.orgwrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
| We are using c# windows forms and just trying to get started with .net.
I
| want to do something that should be easy but I can't find any way to
make
it
| work. We are using Click Once to publish to a network drive and I need
to
be
| able to check if a program is the current version. Because the users
can
| choose to not download the latest version this may be a problem. I just
want
| to show what version they are running.

Try:
System.Reflection.Assembly.GetExecutingAssembly() .GetName().Version.ToString();--Ignacio
Machinmachin AT laceupsolutions com


Feb 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
8
by: Michael A. Covington | last post by:
Is there a way to make a C# program print the date on which it was compiled? Finding the file date of the executable is one way, but it's not foolproof. Thanks!
2
by: HC | last post by:
Hello, Folks. I am not sure if this can be done (and a brief search of this group didn't yield any results that I thought would do the trick) but if it can be done it would make my life easier so...
9
by: ehabaziz2001 | last post by:
I am facing that error message with no idea WHY the reason ? "Abnormal program termination" E:\programs\c_lang\iti01\tc201\ch06\ownarr01o01 Enter a number : 25 More numbers (y/n)? y...
0
by: georges the man | last post by:
The purpose: • Sorting and Searching • Numerical Analysis Design Specification You are to write a program called “StockAnalyser”. Your program will read a text file that contains historical...
4
by: georges the man | last post by:
hey guys, i ve been posting for the last week trying to understand some stuff about c and reading but unfortunaly i couldnt do this. i have to write the following code. this will be the last...
8
by: Nasutperaah | last post by:
Hi all, I have written a C ++ program and now need to add a way to make it exit on command, or start over from the beginning. I have very little programming knowledge; Here is my code: Thanks in...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
1
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.