in AssemblyInfo.cs file I have following subection:
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[ass开发者_StackOverflow社区embly: AssemblyConfiguration("Release")]
#endif
Where this information can be seen after assembly is built ? Since there is nothing about it in file details:
where else can it be found ?
Regards
You can use reflection to get this information. I believe it would be something like the following.
Assembly assembly = Assembly.GetExecutingAssembly();
object[] attributes = assembly.GetCustomAttributes(true);
var config = attributes.OfType<AssemblyConfigurationAttribute>().FirstOrDefault();
if (config != null) {
Debug.WriteLine(config.Configuration);
}
Thinking about it further is this your intent?
How to check if an assembly was built using Debug or Release configuration?
The blogpost linked from the top answer shows a better way to determine if the assembly is Debuggable: http://stevesmithblog.com/blog/determine-whether-an-assembly-was-compiled-in-debug-mode/
One answer indicates that if you use the AssemblyDescription attribute to conditionally include Release/Debug in the text you can have that information in Windows Explorer.
You can use ILDASM.exe to look at the compiled assembly. See http://msdn.microsoft.com/en-us/library/ceats605.aspx for info on using ILDASM.exe.
Or you may use Reflection to look at it via code, such as
System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes()
The Windows Explorer property sheet pulls that information from the win32 VERSIONINFO resources. A number of assembly attributes can be mapped to win32 resource fields (and will be set by the build) but it may be that the AssemblyConfiguration
attribute is not one of them.
If you want to look at all assembly attributes, including those that don't set win32 resource fields, .NET Reflector is one option.
精彩评论