要調用哪個Activator.CreateInstance重載函數?我有一個從 返回的類型「Type proxyType = GetProxyType(contractType);」和constructorinfo是要調用哪個Activator.CreateInstance重載函數?
「[System.Reflection.RuntimeConstructorInfo] = {無效.ctor(System.ServiceModel.InstanceContext)} 基{System.Reflection.MemberInfo} = {空隙.ctor(System.ServiceModel.InstanceContext) }
[System.Reflection.RuntimeConstructorInfo] = {無效.ctor(System.ServiceModel.InstanceContext,System.String)} 基{System.Reflection.MethodBase} = {空隙.ctor(System.ServiceModel.InstanceContext, System.String)}
[System.Reflection.RuntimeConstructorInfo] = {Void .ctor(System.ServiceModel.InstanceContext,System.String,System.String)} base {System.Reflection.MethodBase} = {Void .ctor(System.ServiceModel.InstanceContext,System.String,System.String)}
[System.Reflection.RuntimeConstructorInfo] = {Void .ctor(System.ServiceModel .InstanceContext,System.String,System.ServiceModel.EndpointAddress)} 基{System.Reflection.MethodBase} = {空隙.ctor(System.ServiceModel.InstanceContext,System.String,System.ServiceModel.EndpointAddress)}
[System.Reflection.RuntimeConstructorInfo] = {Void .ctor(System.ServiceModel.InstanceContext,System.ServiceModel.Channels.Binding,System.ServiceModel.EndpointAddress)} base {System.Reflection.MethodBase} = {Void .ctor(System .ServiceModel.InstanceContext,System.ServiceModel .Channels.Binding,System.ServiceModel.EndpointAddress)}。
謝謝!
謝謝達林。我以爲Activator.CreateInstance(proxyType)也是。但它引發了我「爲此對象定義的無參數構造函數」。在System.RuntimeType.CreateInstanceSlow(布爾publicOnly,布爾fillCache) (在System.RuntimeType.CreateInstanceImpl())上的堆棧報告位於System.RuntimeTypeHandle.CreateInstance(RuntimeType類型,Boolean publicOnly,Boolean noCheck,Boolean和canBeCached,RuntimeMethodHandle&ctor,Boolean&bNeedSecurityCheck)布爾publicOnly,布爾skipVisibilityChecks,布爾fillCache) .... – Don 2010-03-24 20:37:08
請參閱我的更新。 – 2010-03-24 20:49:12
達林,我們可以得到一個InstanceContext來執行proxyType嗎? OperationContext.Current.InstanceContext似乎是執行當前服務的一個。 – Don 2010-03-25 15:57:36