Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将fody weavers应用于整个解决方案_C#_Visual Studio_Fody - Fatal编程技术网

C# 将fody weavers应用于整个解决方案

C# 将fody weavers应用于整个解决方案,c#,visual-studio,fody,C#,Visual Studio,Fody,我正在尝试设置Tracer.Fody,当我将它添加到一个项目中时,它可以完美地工作。但是,我希望为整个解决方案设置跟踪日志,并仅使用一个FodyWeavers.xml对其进行配置。是否可以仅在主项目上设置Fody,并告诉它通过依赖项进行编织?使用模块在父项目中实现装饰器 [module: RelayExceptions] [AttributeUsage(AttributeTargets.Method)] public class RelayExceptionsAttribute : At

我正在尝试设置Tracer.Fody,当我将它添加到一个项目中时,它可以完美地工作。但是,我希望为整个解决方案设置跟踪日志,并仅使用一个FodyWeavers.xml对其进行配置。是否可以仅在主项目上设置Fody,并告诉它通过依赖项进行编织?

使用模块在父项目中实现装饰器

[module: RelayExceptions]
[AttributeUsage(AttributeTargets.Method)]
    public class RelayExceptionsAttribute : Attribute, IMethodDecorator
    {
        public void Init(object instance, MethodBase method, object[] args)
        { }
        public void OnException(Exception exception)
        {
            Console.WriteLine(exception.Message);
        }
        public void OnEntry() { }

        public void OnExit() { }
    }
在另一个有参考的项目中提到[module:RelayExceptions],它应该可以工作

[module: RelayExceptions]

class Test{
[RelayExceptions]
public void AnyMethod()
{
//some code
}
}
注意:这在MethodDecorator 1.1.0中起作用