ElektroStudios ElektroStudios - 2 years ago 504
Vb.net Question

Exception: Application identity is not set

I'm having this exception when trying to use any of the Deployment members like for example I try in this simple code:

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

MsgBox(If(My.Application.Deployment.IsFirstRun, "Yes", "No"))

End Sub

End Class

Exception message:
Application identity is not set

The exception occurs in debugging and also in release, in VS2012, targeting FW 4.0 in a Winforms.

I've read here: Application identity not set Exception

...And also here: InvalidDeploymentException - Application identity is not set

I don't remember how to deactivate the exception checking in the project settings but anyways there is a way to avoid this exception without manually disabling exceptions?

The reason is just I don't want to manually disable exceptions and remember to do it for each of my stored and future projects, I want to fix this problem in a natural way.

Answer Source

Is it a ClickOnce application? It is network deployed? Are you debugging? That would not work in debug mode.

If you are debugging, use this to test:

If Not System.Diagnostics.Debugger.IsAttached Then
    firstRun = My.Application.Deployment.IsFirstRun
End If


As it is not a network deployed application, I would check if the application has been previously launched saving a user settings or establishing a value in the registry.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download