Not Monitored
Tag not monitored by Microsoft.
37,794 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I am migrating the extension project from VS2019 to VS2022.
I found that IVSMDPropertyGrid.SetSelectedObjects was changed in VS2022.
VS2019: SetSelectedObjects(Int32, Int32)
this.grid.SetSelectedObjects(1, (Int32)ppUnk);
VS2022: SetSelectedObjects(Int32, IntPtr[])
this.grid.SetSelectedObjects(1, new IntPtr[] { ppUnk });
Where parameter is changed from Int32 to IntPtr[]. I updated the code to handle array, but it failed with error 0x80004005.
IntPtr p = Marshal.GetIUnknownForObject(this);
IntPtr ppUnk = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPtr)));
Marshal.WriteIntPtr(ppUnk, p);
this.BindProperties();
**this.grid.SetSelectedObjects(1, new IntPtr[] { ppUnk });**
this.grid.Refresh();
Need help on the migration.
Thanks in advance.
Regards,
Som
I found the solution of the issues, below code resolves the error.
IntPtr[] intPtrs = new IntPtr[1];
Marshal.Copy(ppUnk, intPtrs, 0, 1);
this.grid.SetSelectedObjects(1, intPtrs);