【发布时间】:2013-09-30 19:19:26
【问题描述】:
我有一个通用委托,它在这样的单例类中实现;
public class BBCacheMethods
{
private static BBCacheMethods instance;
private BBCacheMethods() { }
public static BBCacheMethods Instance
{
get
{
if (instance == null)
{
instance = new BBCacheMethods();
}
return instance;
}
}
public T GetResUstPolitikaBelgeTurlerisForCache<T>() where T:class
{
return null;
}
public delegate T MethodToInvokeDelegate<T>();
public static MethodToInvokeDelegate<T> MethodToInvoke<T>() where T : class
{
MethodInfo method = Instance
.GetType()
.GetMethod("GetResUstPolitikaBelgeTurlerisForCache");
if (null != method)
{
return (MethodToInvokeDelegate<T>)Delegate.CreateDelegate(
typeof(MethodToInvokeDelegate<T>),
Instance,
method);
}
else
throw new FaultException("");
}
当我调用委托时收到此错误:
无法绑定到目标方法,因为它的签名或安全透明度与委托类型的不兼容。
调用委托的类是这样调用的:
public static void loadCache<T>() where T : class
{
var aa = BBCacheMethods.MethodToInvoke<T>();
}
我不知道为什么会收到这样的错误,感谢任何帮助。
【问题讨论】: