dirk.eyfrig

DxD: Automation crashing with COM-Exception

Discussion created by dirk.eyfrig on Jun 29, 2010
Latest reply on Jul 2, 2010 by dirk.eyfrig

Has anybody got an idea what could be the reason for frequent crashes on larger designs with this code:

 

The line starting with the -> is where the error occurs...

 

 

Private Sub RestoreCompValues()

    Dim dxObjs As ViewDraw.CVdObjs
    Dim dxComp As ViewDraw.CVdComp
    Dim valAttr As ViewDraw.CVdAttr
    Dim i As Long
    Dim dsnName As String
    Dim topSch As String

    dsnName = dxdApp.ActiveView.GetTopLevelDesignName
    topSch = dxdProj.GetiCDBDesignRootBlock(dsnName)
    dxObjs = dxdApp.DesignComponents("", topSch, -1, "", True)
    For i = 1 To dxObjs.Count
        dxComp = dxObjs.Item(CInt(i))
        If Not dxComp Is Nothing Then
->                If dxComp.Refdes <> "" Then
                If dxComp.GetBatchOats.Contains("Part Name=[") Then
                    valAttr = dxComp.FindAttribute("Part Name")
                    valAttr.InstanceValue = valAttr.Value
                    valAttr.InstanceValue = valAttr.InstanceValue.Substring(2, valAttr.InstanceValue.Length - 2)
                    valAttr.SetAutomaticColor(True)
                End If
            End If
        End If
    Next
    dxdApp.ActiveView.Block.DeSelectAll()

End Sub


Error: COM-Exception: Unable to allocate object

System.Runtime.InteropServices.COMException wurde nicht behandelt.
  ErrorCode=-2147220862
  HelpLink="C:\Programme\MentorGraphics\2007.8EE\SDD_HOME\wv\win32\bin\viewdraw.HLP#393346"
  Message="Unable To Allocate Object Collection"
  Source="DxDesigner"
  StackTrace:
       bei ViewDraw.IVdComp.get_Refdes()
       bei DxD_GenVariantMaster.frmMain.RestoreCompValues() in C:\Dokumente und Einstellungen\eyfridi\Eigene Dateien\VB2005_Projects\DxD_CreateVariantMaster\frmMain.vb:Zeile 475.
       bei DxD_GenVariantMaster.frmMain.butReplValAttr_Click(Object sender, EventArgs e) in C:\Dokumente und Einstellungen\eyfridi\Eigene Dateien\VB2005_Projects\DxD_CreateVariantMaster\frmMain.vb:Zeile 617.
       bei System.Windows.Forms.Control.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnClick(EventArgs e)
       bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       bei System.Windows.Forms.Control.WndProc(Message& m)
       bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
       bei System.Windows.Forms.Button.WndProc(Message& m)
       bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       bei System.Windows.Forms.Application.Run(ApplicationContext context)
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       bei DxD_GenVariantMaster.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81.
       bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()

Outcomes