.net - Reason why MethodBuilder.DefineParameter could not set parameter name? -


I'm making interface based on an existing interface for WCF concerns, but I do not set "DefineParameter" parameter name (The type of method of made type is not a name).
Are you a reason to do that?

  public static type MakeWcfInterface (type iService) {AssemblyName AssemblyName = new AssemblyName (see the string. Format ( "{0} _DynamicWcf", iService.FullName)); String modulation name = string.format ("{0} .dll", assemblyName.Name); String ns = iService.Namespace; If (! String.IsNullOrEmpty (ns)) ns + = "."; // Create assembly assembly assembly = AppDomain.CurrentDomain.DefineDynamicAssembly (assembly name, AssemblyBuilderAccess.RunAndSave); // modules create var modules = assembly. Defined dynamic module (module name, incorrect); // asynchronous interface type Create TypeBuilder iWcfService = module.DefineType (| TypeAttributes.Interface | String.Format ( "{0} DynamicWcf", iService.FullName), TypeAttributes.Public TypeAttributes.Abstract); // set ServiceContract iWcfService.SetCustomAttribute (; ServiceContractAttribute & gt; (Zero, New Dictionary & LT; string, object & gt; () {{ "name", iService.Name}}) to ReflectionEmitHelper.BuildAttribute & lt) attributes Are; iWcfService.SetCustomAttribute (ReflectionEmitHelper.BuildAttribute & LT; ServiceBehaviorAttribute & gt; (Zero, New Dictionary & LT; string, object & gt; () {{ "InstanceContextMode", InstanceContextMode.Single}})); Foreign Currency (Different Methods in iService.GetMethods ()) {BuildWcfMethod (iWcfService, Method); } Return iWcfService.CreateType (); } Private static MethodBuilder BuildWcfMethod (TypeBuilder goal, MethodInfo template) {// define method var method = target.DefineMethod (template.Name, MethodAttributes.Abstract | MethodAttributes.Virtual | MethodAttributes.FamANDAssem | MethodAttributes.Family | MethodAttributes.VtableLayoutMask | MethodAttributes. HideBySig, Calling Conventions, Standards, Templates. Return, Templates. GetParameters (.) Select (P => P. Parameter Type) .Oere ()); // Define parameter foreach (ParameterInfo param.GetParameters (template) in template {method.DefineParameter (param.Position, ParameterAttributes.None, param.Name); } // Set Operation Contract Attribute Method Set custom audit (Reflection AmitHalper.bilt attribute & lt; Operation ContractActivate & gt; (blank, empty)); Return method; }  

I got it, so I told you.
Answer is the way I used the DefineParameter function.
The GetParameters function gives information about the parameters of the method provided.
But set the parameter function defined for all the parameters (including the return parameter), so using the PostScript shift: DefineParameter, position 0 reference return parameter, and call parameters start in position 1.

OK See:

  method.DefineParameter (param.Position + 1, ParameterAttributes.None, Ultimate. Name); 

HTML

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -