Loading stencil into mdi axdrawingcontrol windows

Started by EenOog, July 27, 2011, 06:08:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EenOog

morning guys

we have a C# application using visio drawing control, we get to create multiple instances of our windows as to allow users to createor work on multiple documents at the same time. my problemis when we try and load the stencil to each one of these windows i get the following com exception was un handeled with error message =  Requested operation is presently disabled.

System.Runtime.InteropServices.COMException was unhandled
  Message= Requested operation is presently disabled.



    •   Source=Microsoft Visio
        ErrorCode=-2032465766
        StackTrace:
             at Microsoft.Office.Interop.Visio.DocumentClass.OpenStencilWindow()
             at Coach.UI.CoachDocumentView.LoadInterop() in C:\st work\Coach\G - Development\Source Code\Coach.UI\Views\CoachDocument\CoachDocumentView.cs:line 116
             at Coach.UI.CoachDocumentView.CoachDocumentView_Load(Object sender, EventArgs e) in C:\st work\Coach\G - Development\Source Code\Coach.UI\Views\CoachDocument\CoachDocumentView.cs:line 58
             at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
             at System.Windows.Forms.UserControl.OnCreateControl()
             at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
             at System.Windows.Forms.AxHost.EndInit()
             at Coach.UI.CoachDocumentView.InitializeComponent() in C:\st work\Coach\G - Development\Source Code\Coach.UI\Views\CoachDocument\CoachDocumentView.Designer.cs:line 80
             at Coach.UI.CoachDocumentView..ctor() in C:\st work\Coach\G - Development\Source Code\Coach.UI\Views\CoachDocument\CoachDocumentView.cs:line 50
             at Coach.UI.CoachMainView.radButtonNew_Click(Object sender, EventArgs e) in C:\st work\Coach\G - Development\Source Code\Coach.UI\CoachMainView.cs:line 82
             at Telerik.WinControls.RadItem.OnClick(EventArgs e)
             at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
             at Telerik.WinControls.RadItem.DoClick(EventArgs e)
             at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
             at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
             at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
             at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
             at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
             at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e)
             at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
             at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
             at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
             at System.Windows.Forms.Control.WndProc(Message& m)
             at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
             at Telerik.WinControls.RadControl.WndProc(Message& m)
             at Telerik.WinControls.UI.RadRibbonBar.WndProc(Message& m)
             at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
             at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
             at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
             at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
             at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
             at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
             at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
             at System.Windows.Forms.Application.Run(Form mainForm)
             at Coach.UI.Program.Main() in C:\st work\Coach\G - Development\Source Code\Coach.UI\Program.cs:line 24
             at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
             at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
             at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
             at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
             at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
             at System.Threading.ThreadHelper.ThreadStart()
        InnerException:


      // okay now lets load the stencil
                  // get the current draw page
                  Microsoft.Office.Interop.Visio.Page currentPage = axDrawingControl1.Document.Pages[1];

                  // Load the stencil we want
                  Microsoft.Office.Interop.Visio.Document currentStencil = axDrawingControl1.Document.Application.Documents.OpenEx(path + Properties.Settings.Default.stecilName,
                  (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
                  // show the stencil window
                  //Microsoft.Office.Interop.Visio.Window stencilWindow;
this bad boy seems to be causing the error, if i comment it out the stencil is still loaded, my problem is when i click other document tab i need to set the stencil to the current active document

            Microsoft.Office.Interop.Visio.Window stencilWindow = currentPage.Document.OpenStencilWindow();


i need to be able when i click my document tab to set the stencil to the active window,  i already have a method that check for the active document that we use to save or save as.

thanks for all your help in advance

regards
EenOog