سؤال

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.

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top