在AssemblyInfo.cs文件我有以下subection:在哪裏可以找到裝配配置信息?
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
在這個信息可以在組裝之後可以看到建?由於沒有任何關於它的文件的詳細信息:
還有什麼地方能不能找到?
問候
在AssemblyInfo.cs文件我有以下subection:在哪裏可以找到裝配配置信息?
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
在這個信息可以在組裝之後可以看到建?由於沒有任何關於它的文件的詳細信息:
還有什麼地方能不能找到?
問候
Windows資源管理器屬性頁翻出從Win32 VERSIONINFO資源信息。許多程序集屬性可以是mapped to win32 resource fields(並且將由內部版本設置),但它可能是屬性不是其中之一。
如果您想查看所有裝配屬性,包括那些不設置win32資源字段的裝配屬性,.NET Reflector是一種選擇。
您可以使用ILDASM.exe查看編譯後的程序集。有關使用ILDASM.exe的信息,請參閱http://msdn.microsoft.com/en-us/library/ceats605.aspx。
或者你可以使用反射通過代碼來看待它,如 System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes()
您可以使用反射來獲取這些信息。我相信它會像下面這樣。
Assembly assembly = Assembly.GetExecutingAssembly();
object[] attributes = assembly.GetCustomAttributes(true);
var config = attributes.OfType<AssemblyConfigurationAttribute>().FirstOrDefault();
if (config != null) {
Debug.WriteLine(config.Configuration);
}
想進一步這是你的意圖嗎?
How to check if an assembly was built using Debug or Release configuration?
從上面的答案鏈接博客帖子顯示了更好的方式,以確定是否該組件可調試:http://stevesmithblog.com/blog/determine-whether-an-assembly-was-compiled-in-debug-mode/
一個答案表明,如果使用AssemblyDescription屬性有條件地包括髮布/調試中您可以在Windows資源管理器中獲得這些信息。
我將用'var config = attributes.OfType()。FirstOrDefault();'替換第三行。那麼你不需要演員,它看起來有點清潔imho。 –
2015-06-24 12:44:32