小编Ser*_*iel的帖子

在发布版本中省略代码

我在跟踪方法等的.net库中使用了smartinspect.但是对于发布配置,我想避免部署smartinspect以及跟踪代码中的所有内容的开销.有没有一种简单的方法来实现这一点,而不是每次调用方法时都使用编译器指令?

示例代码:

    public bool OpenDocument(string srcFile)
    {
        SiExportWordSession.EnterMethod(this, "OpenDocument");
        try
        {
            SiExportWordSession.LogString("srcFile", srcFile);

            try
            {
                _doc = new Document(srcFile);
                return true;
            }
            catch (Exception e)
            {
                SiExportWordSession.LogException(e);
                ErrorName = e.GetType().Name;
                ErrorMessage = e.Message;
                return false;
            }
        }
        finally
        {
            SiExportWordSession.LeaveMethod(this, "OpenDocument");
        }
    }
Run Code Online (Sandbox Code Playgroud)

我的第一个想法是为smartinspect创建一个包装器,它可以调用smartinspect或什么也不做,具体取决于发布配置.但这不会让我摆脱尝试最终的构造.有没有更好的方法来解决这个问题?

.net c# dll smartinspect

1
推荐指数
1
解决办法
54
查看次数

标签 统计

.net ×1

c# ×1

dll ×1

smartinspect ×1