To make my console application launch after install I have added an installer class to my project.
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(this.Context.Parameters["AssemblyPath"]) + @"\MyAppName.exe");
}
I have added custom actions to my SetupProject
(shortcut to Primary output MyApp.exe
under Install and Commit) to execute launch after install and it does launch the app.
However when the app launches after install, and Main()
runs UserPrincipal.Current.EmailAddress;
I get this error:
Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'.
(This is on my workplace network by the way).
Now if I go to the application folder and run the .exe.... it works.
So my question is: what is it about the "run after install" method that's making this happen and how can I fix it?
I've tried almost every corner of the internet but cant get my head around this and many other solutions haven't worked.
I've tried solutions from this SO post with no luck.
I've tried getting the email address from outlook instead but I get a different error (which doesnt happen during debug or from clicking the .exe).