Question

I need to set the current AppDomain to what I create.

I want to Log my application exception using Enterprise Library HandleException method. When I handle the exception, it will insert a log into a logging table, and sets the AppDomainName field with System.AppDomain.CurrentDomain.FriendlyName that is meaningless.

I want to have my own FriendlyName for my Application.

Was it helpful?

Solution

You cannot set the current application domain.

The AppDomain.FriendlyName property by default has the value of the application file name (Read the remarks section). You cannot change this in the default application domain.

What you can change is the name of your executable assembly. You can change it from your project's properties. Then you can use it like this:

Assembly.GetEntryAssembly().GetName().Name

which always returns the name of the process executable assembly.

OTHER TIPS

Assembly.GetEntryAssembly().GetName().Name remains the same when the executable is renamed. Use Assembly.GetEntryAssembly().Location for the executable file name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top