By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,463 Members | 1,528 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,463 IT Pros & Developers. It's quick & easy.

Program Version Number

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.