How to set AppDomain FriendlyName in ClickOnce script?

FriendlyName seems to get the value "DefaultDomain" when the application is deployed using ClickOnce instead of the exe name. I would like to eliminate my windows from other potential ClickOnce applications, which could also be "DefaultDomain".

Clarification: We are using an unmanaged call.

[DllImport("user32.dll")]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

to get the class name for the windows around the user's desktop, and you need to make sure that we react in a certain way to the windows created by our application. When deployed with ClickOnce, our windows no longer contain the exe name as a domain and will not easily differ from other potential applications deployed by ClickOnce.

+5
source share
1 answer

Great question.

I can’t say exactly why this is so, but I think that maybe the application is “hosted” differently, as it is the “ClickOnce Application Deployment Support Library” that launches the application.

However, if you have an inexorable desire to use AppDomain.FriendlyName to distinguish your applications, then perhaps you could create an appdomain yourself and define your own friendly name.

Another idea that would serve the same purpose would be to use the full name of the application as follows:

private static string GetAppName()
{
    if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
    {

        ApplicationDeployment curDeployment = ApplicationDeployment.CurrentDeployment;
        string fullname = curDeployment.UpdatedApplicationFullName;
        Match match = Regex.Match(fullname, "#.+/(?<app>.+).exe");

        return match.Groups["app"].ToString();
    }
    return null;
}

, . , : http://blogs.msdn.com/b/shawnfa/archive/2004/06/30/170241.aspx

- , .

+1

All Articles