473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(ob ject sender, EventArgs e)
{
FileVersionInfo fvi =
FileVersionInfo .GetVersionInfo (Application.Ex ecutablePath);
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 .SecurityExcept ion was unhandled
Message="Reques t failed."
Source="AfterSc hool1"
Feb 1 '07 #1
3 12903
Hi,
"Bill Cart" <bc***@RemoveTh is.lifecarealli ance.orgwrote in message
news:OH******** ******@TK2MSFTN GP04.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.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). Version.ToStrin g();--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.Deploym ent.Application .ApplicationDep loyment.IsNetwo rkDeployed)
{
Version version =
System.Deployme nt.Application. ApplicationDepl oyment.CurrentD eployment.Curre ntVersion;
string versionString = version.ToStrin g();
}

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
Hi,
"Bill Cart" <bc***@RemoveTh is.lifecarealli ance.orgwrote in message
news:OH******** ******@TK2MSFTN GP04.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.Reflecti on.Assembly.Get ExecutingAssemb ly().GetName(). Version.ToStrin g();--Ignacio
Machinmachin AT laceupsolutions com

Feb 1 '07 #3
I tried the System.Deployme nt method
System.Deployme nt.Application. ApplicationDepl oyment ad1 =
System.Deployme nt.Application. ApplicationDepl oyment.CurrentD eployment;
System.Windows. Forms.MessageBo x.Show(ad1.Curr entVersion.ToSt ring());

but when I test it I get the following error:

System.Deployme nt.Application. InvalidDeployme ntException was unhandled
Message="Applic ation 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******** *****@TK2MSFTNG P02.phx.gbl...
For ClickOnce, that won't give the current version number... instead (from
a post by Andrej Tozon):

if (System.Deploym ent.Application .ApplicationDep loyment.IsNetwo rkDeployed)
{
Version version =
System.Deployme nt.Application. ApplicationDepl oyment.CurrentD eployment.Curre ntVersion;
string versionString = version.ToStrin g();
}

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>Hi,
"Bill Cart" <bc***@RemoveTh is.lifecarealli ance.orgwrote in message
news:OH******* *******@TK2MSFT NGP04.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.Reflect ion.Assembly.Ge tExecutingAssem bly().GetName() .Version.ToStri ng();--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
8809
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 feedback on how I might do things differently to make it either more consice, readable, or faster. ie... are there better ways to do it in Python? It won't break any records for calculating pi, that wasn't my goal, learning Python was. But it might...
8
22493
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
2494
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 here goes. First, what I am trying to accomplish is to make a program I've written automatically update itself if there is a newer version on the network. Second, my application runs on one or more computers at many geographically separated...
9
6908
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 Enter a number : 30 More numbers (y/n)? n
0
2428
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 price of a stock. The program will allow users to query the stock price of a particular date and output its statistics (mean price, median price and standard deviation) for any specified period. Your program must be menu driven and works as follows.
4
2767
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 time i ask for an entire code or u can give me the outine of what to do and i ll do it by myself. the description is the following: the program will read a text file that contains historical price of a stock. The program will allow users to query...
8
29131
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 advance for any help. /////////////////////////////////////////////////////////////////////////////////////////////////// // ...
69
5598
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 signature for the method (i.e., as below, int Square (int)). Here is an example to show that feature. Note class "UnAwareClass" has its methods Square and Cuber called by a class DelegateClass. This is because these methods in UnAwareClass have the...
1
2077
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 is about 3 and a half pages of code long it does some relatively simple math additions and subtractions The problem I have is that some numbers get to be very large integers and VB automatically converts this to scientifc notation, what I need is...
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.