views:

745

answers:

4

I have a windows forms application that is deployed to two different locations.

  • Intranet - ClickOnce
  • Internet - Installed on a citrix farm through Windows installer

I display ClickOnce version number for click-once deployed versionApplicationDeployment.IsNetworkDeployed.

if (ApplicationDeployment.IsNetworkDeployed)
        return ApplicationDeployment.CurrentDeployment.CurrentVersion;

But for the non-click application, I am not sure how to retrieve clickonce version unless I hardcode the version number in assembly info.

Is there an automatic way of retrieve ClickOnce version number for non-clickonce deployed version?

+8  A: 

No I do not believe that there is a way. I believe the ClickOnce information comes from the manifest which will only be available in a ClickOnce deployment. I think that hard coding the version number is your best option.

JaredPar
@JaredPar: Thank you and I will actually try to leave the question open to see if anyone has encountered the similar situation and was able to come up with some work-arounds.
Sung Meister
+2  A: 

Hard code, or... Keep track on your versions (File, Assembly, Deploy) in a database. Make a call to the database with your Assembly and get the Deploy version.

This assumes that you are incrementing your versions in a logical way such that each version type has a relationship. It's a lot of work for such a minor problem. I'd personally go with Jared's solution; although I hate hard coding anything.

Coov
@Coov: " I hate hard coding anything" That is exactly why I was thinking about if there was a way to get around this. I have not thought about database to keep track of version numbers. Thank you for another way to solve this issue.
Sung Meister
+2  A: 

I would simply make the assembly version of the main assembly the same as the CLickOnce version every time you put out a new version. Then when it runs as a non-clickonce application, just use Reflection to pick up the assembly version.

RobinDotNet
+1 for the reflection approach. Thanks, RobinDotNet
Sung Meister
why not use the version of the main assembly when run as clickonce as well?
Ian Ringrose
You have to change the ClickOnce version, or it won't install as an update. I generally try to keep the assembly version and ClickOnce version the same, or at least in the same minor version, depending on what our release versions are going to be.
RobinDotNet
A: 

Using a build component, you could read the click-once version from the project file and write it automatically to the assembly info so both of them are in sync.

Wilhelm