I get the following error intermittently:
CA1804: Microsoft.Performance: 'ChannelFactoryCache.GetChannel (string)' declares a variable '<> s__LockTaken0' of type 'bool', which is never used or assigned. Use this variable or delete it.
for the following code in the first expression if
public static T GetChannel<T>(string endpoint)
{
if (!Cache.ContainsKey(typeof(T)))
{
lock (ObjLock)
{
if (!Cache.ContainsKey(typeof(T)))
{
ChannelFactory<T> channelFactory = new ChannelFactory<T>(endpoint);
channelFactory.Open();
Cache.Add(typeof(T), channelFactory);
}
}
}
T channel = ((ChannelFactory<T>)Cache[typeof(T)]).CreateChannel();
((IChannel)channel).Open();
return channel;
}
Any idea what I'm doing wrong? CA runs in release mode.
source
share