Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.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# 以编程方式添加多个Recycling.LogEventOnRecycle事件_C#_.net - Fatal编程技术网

C# 以编程方式添加多个Recycling.LogEventOnRecycle事件

C# 以编程方式添加多个Recycling.LogEventOnRecycle事件,c#,.net,C#,.net,我有: 我遇到的问题是,我不知道如何为LogEventOnRecycle事件分配多个属性。任何帮助都将不胜感激。。。。使用+=instat of=已经有很多年了,因为它会添加而不会覆盖某些内容。根据MSDN,是一种类型,它是一个枚举,具有一个FlagsAttribute属性,允许其成员值按位组合 因此,以下几点应该适合您: ApplicationPool BOB = iisManager.ApplicationPools.Add("BOB"); BOB.Recycling.Log

我有:

我遇到的问题是,我不知道如何为LogEventOnRecycle事件分配多个属性。任何帮助都将不胜感激。。。。使用+=instat of=已经有很多年了,因为它会添加而不会覆盖某些内容。

根据MSDN,是一种类型,它是一个枚举,具有一个FlagsAttribute属性,允许其成员值按位组合

因此,以下几点应该适合您:

    ApplicationPool BOB = iisManager.ApplicationPools.Add("BOB");
    BOB.Recycling.LogEventOnRecycle = RecyclingLogEventOnRecycle.OnDemand;
    BOB.Recycling.LogEventOnRecycle = RecyclingLogEventOnRecycle.IsapiUnhealthy;

请注意,您需要使用逻辑位或运算符|,而不是加法运算符+

@Stelly你能把LogEventOnRecycle的声明贴出来吗?谢谢S先生。非常感谢:D
    RecyclingLogEventOnRecycle myRecycleEvents = 
        RecyclingLogEventOnRecycle.OnDemand | RecyclingLogEventOnRecycle.IsapiUnhealthy;
    ApplicationPool BOB = iisManager.ApplicationPools.Add("BOB");
    BOB.Recycling.LogEventOnRecycle = myRecycleEvents;