protected virtual int ShowObjectBrowser()
{
if(String.IsNullOrEmpty(this.Url) || !File.Exists(this.Url))
{
return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
}
// Request unmanaged code permission in order to be able to creaet the unmanaged memory representing the guid.
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
Guid guid = VSConstants.guidCOMPLUSLibrary;
IntPtr ptr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(guid.ToByteArray().Length);
System.Runtime.InteropServices.Marshal.StructureToPtr(guid, ptr, false);
int returnValue = VSConstants.S_OK;
try
{
VSOBJECTINFO[] objInfo = new VSOBJECTINFO[1];
objInfo[0].pguidLib = ptr;
objInfo[0].pszLibName = this.Url;
IVsObjBrowser objBrowser = this.ProjectManager.Site.GetService(typeof(SVsObjBrowser)) as IVsObjBrowser;
ErrorHandler.ThrowOnFailure(objBrowser.NavigateTo(objInfo, 0));
}
catch(COMException e)
{
Trace.WriteLine("Exception" + e.ErrorCode);
returnValue = e.ErrorCode;
}
finally
{
if(ptr != IntPtr.Zero)
{
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(ptr);
}
}
return returnValue;
}