欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

判断dll是版本(Debug Or Release)[测试通过]

发布时间:2025/3/11 32 豆豆
生活随笔 收集整理的这篇文章主要介绍了 判断dll是版本(Debug Or Release)[测试通过] 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

简单的代码,google搜索提炼和分析,主要是利用反射技术,测试通过,抛砖引玉,自娱自乐,多多指教。

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);
}
}

总结

以上是生活随笔为你收集整理的判断dll是版本(Debug Or Release)[测试通过]的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。