Display Publish Version Error

G

Guest

Error occurs on
"System.Deployment.Application.ApplicationDeployment.CurrentDeployment"


** Here is my code

private void frmMain_Load(object sender, System.EventArgs e)
{
System.Deployment.Application.ApplicationDeployment ad =
System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
this.Text = "Dealer Sales " + ad.CurrentVersion;

}


** Here is the error message

System.Deployment.Application.InvalidDeploymentException was unhandled
Message="Application is not installed."
Source="System.Deployment"
StackTrace:
at System.Deployment.Application.ApplicationDeployment..ctor(String
fullAppId)
at
System.Deployment.Application.ApplicationDeployment.get_CurrentDeployment()
at LicenseDealerSales.frmMain.frmMain_Load(Object sender, EventArgs
e) in C:\Documents and Settings\mikel\My Documents\Visual Studio
Projects\LicenseDealerSales\frmMain.cs:line 131
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
hWnd, Int32 msg, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at LicenseDealerSales.frmMain.Main() in C:\Documents and
Settings\mikel\My Documents\Visual Studio
Projects\LicenseDealerSales\frmMain.cs:line 106
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
M

Marc Gravell

You need to check ApplicationDeployment.IsNetworkDeployed; if this returns
false there is no publication to get an application version from - so the
best you can use is the assembly version via something like
System.Reflection.Assembly.GetEntryAssembly().GetName().Version

Marc
 
T

TerryFei

Hi Cadel,
Thanks for Marc's reply!

I just wanted to check how things are going and whether Marc's suggestion
is useful for you. If there is any question, please feel free to join the
community and we are here to support you at your convenience. Thanks for
your understanding!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
Thread-Topic: Display Publish Version Error
thread-index: AcY4ktXA/ASPLjhKQMuzDVzXcMDU0w==
X-WBNR-Posting-Host: 204.87.106.66
From: =?Utf-8?B?TWlrZSBM?= <[email protected]>
Subject: Display Publish Version Error
Date: Thu, 23 Feb 2006 08:04:32 -0800
Lines: 74
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.languages.csharp:387990
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp


Error occurs on
"System.Deployment.Application.ApplicationDeployment.CurrentDeployment"


** Here is my code

private void frmMain_Load(object sender, System.EventArgs e)
{
System.Deployment.Application.ApplicationDeployment ad =
System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
this.Text = "Dealer Sales " + ad.CurrentVersion;

}


** Here is the error message

System.Deployment.Application.InvalidDeploymentException was unhandled
Message="Application is not installed."
Source="System.Deployment"
StackTrace:
at System.Deployment.Application.ApplicationDeployment..ctor(String
fullAppId)
at
System.Deployment.Application.ApplicationDeployment.get_CurrentDeployment()
at LicenseDealerSales.frmMain.frmMain_Load(Object sender, EventArgs
e) in C:\Documents and Settings\mikel\My Documents\Visual Studio
Projects\LicenseDealerSales\frmMain.cs:line 131
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef
hWnd, Int32 msg, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at LicenseDealerSales.frmMain.Main() in C:\Documents and
Settings\mikel\My Documents\Visual Studio
Projects\LicenseDealerSales\frmMain.cs:line 106
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContex t
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContex t
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone(
)
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
G

Guest

The code brought a number back, but I don't know what it is.
I have the publish version set to 1.0.8.0 but the code brings back
1.0.2249.26117


My new code.

this.Text = "Dealer Sales " +
System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
 
T

TerryFei

Hi Cadel,
Thanks for your response!

The version is composed by four parts. They are Major Version, Minor
Version, Build Number and Revision Number. Based on my knowledge, we can
ignore Build Number and Revision Number. In another word, if Major Version
and Minor Version are equal, these two versions are match. In your current
situation, Major Version and Minor Version of "1.0.8.0" is 1 and 0; Major
Version and Minor Version of "1.0. 2249.26117" is also 1 and 0. So you can
think these two versions are same.

I hope the above information is helpful for you. Thanks for your
understanding!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top