c# - Cannot find the DialogWorkItemDetails method when reflecting the Microsoft.TeamFoundation.VersionControl.Controls assembly -


i attempting utilize existing dialog within microsoft.teamfoundation.versioncontrol.controls assembly show details of tfs work item sent. utilizing reflection this, in similar manner found accessing dialogchangesetdetails method used here.

however, after creating assembly, array object store method arguments, dialogchangesetdetails method cannot found using .createinstance method:

var assembly = assembly.getassembly(typeof (workitempolicy));             var args = new object[] {this, workitem, false};             using (                 var dialog =                     (form)                         assembly.createinstance(                             "microsoft.teamfoundation.versioncontrol.controls.dialogworkitemdetails", false,                             bindingflags.createinstance | bindingflags.nonpublic | bindingflags.instance, null, args,                             cultureinfo.currentculture, null))             {                 if (dialog == null) return;                 dialog.startposition = formstartposition.centerparent;                 dialog.showdialog();             } 

in order ensure not attempting reach method in wrongful manner, used reflector receive information it:

public dialogworkitemdetails(system.windows.forms.iwin32window parent, workitem workitem, bool allowmodification)     {         this.m_workitem = workitem;         this.m_allowmodification = allowmodification;         this.m_workitemstartedoutmodified = this.m_workitem.isdirty;         this.initializewindow();         this.updatebuttons();         this.getworkitemdetails();         new wpfdialogassistant(this)         {             helptopic = "vs.tfc.sourcecontrol.dialogworkitemdetails"         }.setowner(parent.handle);     } 

as far can see, sending method correct parameters, including form parent, work item , whether user can modify work item.

you can find entire dialogworkitemdetails reflected code here.

it turns out since trying access public method, should not have been using bindingflag.nonpublic. updated it, , had change cast since dialog not disposable form.

var assembly = assembly.getassembly(typeof (workitempolicy)); var args = new object[] {this, workitem, true}; var dialog =     (window)         assembly.createinstance(             "microsoft.teamfoundation.versioncontrol.controls.dialogworkitemdetails", false,             bindingflags.createinstance | bindingflags.public | bindingflags.instance, null, args,             cultureinfo.currentculture, null);              if (dialog == null) return;             dialog.showdialog(); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -