判断dll是版本(Debug Or Release)[测试通过]
生活随笔
收集整理的這篇文章主要介紹了
判断dll是版本(Debug Or Release)[测试通过]
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
簡(jiǎn)單的代碼,google搜索提煉和分析,主要是利用反射技術(shù),測(cè)試通過(guò),拋磚引玉,自?shī)首詷?lè),多多指教。
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Assembly ass = Assembly.LoadFile(@"D:\com.uuu9.api.dll");
DebuggableAttribute att = Utils.GetCustomAttribute<DebuggableAttribute>(ass);
Response.Write(att.IsJITTrackingEnabled ? "Debug" : "Release");
}
}
}
public static class Utils
{
public static T GetCustomAttribute<T>(this ICustomAttributeProvider provider)
where T : Attribute
{
var attributes = provider.GetCustomAttributes(typeof(T), false);
return attributes.Length > 0 ? attributes[0] as T : default(T);
}
}
總結(jié)
以上是生活随笔為你收集整理的判断dll是版本(Debug Or Release)[测试通过]的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 把字符串转化为类型
- 下一篇: Matlab仿真炮弹飞行轨迹——探究射弹