I have a desginer that i am trying to open and this designer has an embedded editor. Following is the code:
IVsUIShellOpenDocument shell = (IVsUIShellOpenDocument)DesFMPkg.Instance.GetService(typeof(IVsUIShellOpenDocument));
IOleServiceProvider sp = (IOleServiceProvider)DesFMPkg.Instance.GetService(typeof(IOleServiceProvider));
Guid editorType = GuidList.guidMultiViewEditor;
Guid logicalView = GuidList.guidDesignView;
int hr;
if (des.HasCodeEditorView)
{
IVsSolution vsSolution = (IVsSolution)DesFMPkg.Instance.GetService(typeof(SVsSolution));
object obj;
hr = vsSolution.GetProperty((int)__VSPROPID.VSPROPID_IsSolutionOpen, out obj);
if (!(bool)obj)
{
hr = vsSolution.CreateSolution(string.Empty, string.Empty, (uint)__VSCREATESOLUTIONFLAGS.CSF_TEMPORARY);
}
}
this.m_designer = des;
string caption = "";
// Find the item id assigned to this document by the project.
uint pitemid = VSConstants.VSITEMID_NIL;
string moniker = des.Moniker;
VSVirtualProject project = DesFMPkg.Instance.GetService(typeof(VirtualProject));
IVsUIHierarchy hier = project as IVsUIHierarchy;
IVsProject proj = project as IVsProject;
hr = project.AddDesigner(des, out pitemid);
ErrorHandler.ThrowOnFailure(hr);
hr = shell.OpenSpecificEditor(
(uint)0,
moniker,
ref editorType,
null,
ref logicalView,
caption,//node.Caption,
hier,
pitemid,
System.IntPtr.Zero,
sp,
out editorFrame);
if (ErrorHandler.Succeeded(hr)) {
editorFrame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref GuidList.guidCmdUI_TextEditor);
if (this.DontShowWindow == false)
rrorHandler.ThrowOnFailure(editorFrame.Show());
}
on the EditorFrame.show, i get AccessViolationException. "Attempt to read to write protected memory".
Cam someone help..