Hi there,
Me and my team experienced couple of different exceptions
while trying to constantly create and dispose maps with CadFeatureLayer. I created
a small demo app to highlight these issues and managed to reproduce most of
them. This is what we experienced:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
InnerException: Unable to cast object of type 'Teigha.TD.OdDbDatabase' to
type 'Teigha.TD.OdDbObjectIterator'.
Source: CadDumperX86
StackTrace:
at CadDumper.DwgDxfCadDumper.Dump()
at CadDumper.DwgDxfCadDumper.GetFeatureStyles()
at CadDumper.CadDumper.GetCadFeatures()
Also, second time I got it other way around:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
InnerException: Unable to cast object of type
'Teigha.TD.OdDbObjectIterator' to type 'Teigha.TD.OdDbDatabase'.
Source: CadDumperX86
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target,
Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object
obj, Object[] parameters, Object[] arguments)
at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr,
Binder binder, Object[] parameters, CultureInfo culture)
at
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at
ThinkGeo.MapSuite.Core.CadFeatureSource.iRQ=(String cadPathFileName)
at
ThinkGeo.MapSuite.Core.CadFeatureSource.iBQ=()
at
ThinkGeo.MapSuite.Core.CadFeatureSource.GetAllFeaturesCore(IEnumerable`1
returningColumnNames)
at
ThinkGeo.MapSuite.Core.FeatureSource.GetBoundingBoxCore()
at
ThinkGeo.MapSuite.Core.FeatureSource.GetBoundingBox()
at
ThinkGeo.MapSuite.Core.FeatureLayer.GetBoundingBoxCore()
at
ThinkGeo.MapSuite.Core.Layer.GetBoundingBox()
at
ThinkGeoMapTest.MapControl.<>c__DisplayClass3.<ThinkGeoWpfMap_Loaded>b__2()
in ThinkGeoMapTest\ThinkGeoMapTest\MapControl.xaml.cs:line 43
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)
at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source,
Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at
System.Windows.Threading.DispatcherOperation.InvokeImpl()
at
System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object
state)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at
System.Windows.Threading.DispatcherOperation.Invoke()
at
System.Windows.Threading.Dispatcher.ProcessQueue()
at
System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)
at
MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr
lParam, Boolean& handled)
at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)
at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source,
Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at
System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at
MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam)
at
MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at
System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at
System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at
System.Windows.Threading.Dispatcher.Run()
at
System.Windows.Application.RunDispatcher(Object ignore)
at
System.Windows.Application.RunInternal(Window window)
at
System.Windows.Application.Run(Window window)
at
System.Windows.Application.Run()
at
ThinkGeoMapTest.App.Main() in ThinkGeoMapTest\ThinkGeoMapTest\obj\Debug\App.g.cs:line
0
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.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state, Boolean preserveSyncCtx)
at
System.Threading.ExecutionContext.Run(ExecutionContext executionContext,
ContextCallback callback, Object state)
at
System.Threading.ThreadHelper.ThreadStart()
This example cover adding and disposing only one map.
Trying with more maps that contain CadFeatureLayer with not so big CAD files (~7MB)
produced exceptions like these ones:
************* Inner Exception **************
Exception type:System.InvalidCastException
Exception message:Unable to cast object of type
'Teigha.TD.OdDbRegion' to type 'Teigha.TD.OdDbSymbolTableIterator'.
Exception source:CadDumperX64
Exception Target Site: Dump
at
CadDumper.DwgDxfCadDumper.Dump()
at
CadDumper.DwgDxfCadDumper.GetFeatureStyles()
************** Outer Exception **************
Exception
type:System.Reflection.TargetInvocationException
Exception message:Exception has been thrown by the target
of an invocation.
Exception source:WpfDesktopEdition
Exception Target Site: <DrawException>b__3
at
ThinkGeo.MapSuite.WpfDesktopEdition.Tile.<>c__DisplayClass5.<DrawException>b__3()
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback,
Object args, Int32 numArgs)
at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source,
Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
and
************* Inner Exception **************
Exception type:System.InvalidCastException
Exception message:Unable to cast object of type
'Teigha.TD.OdDbProxyEntity' to type 'Teigha.TD.OdDbDatabase'.
Exception source:CadDumperX64
Exception Target Site: Dump
at CadDumper.DwgDxfCadDumper.Dump()
at
CadDumper.DwgDxfCadDumper.GetFeatureStyles()
************* Outer Exception **************
Exception
type:System.Reflection.TargetInvocationException
Exception message:Exception has been thrown by the target
of an invocation.
Exception source:WpfDesktopEdition
Exception Target Site: <DrawException>b__3
at
ThinkGeo.MapSuite.WpfDesktopEdition.Tile.<>c__DisplayClass5.<DrawException>b__3()
at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object
args, Int32 numArgs)
at
MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source,
Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
I’m using version 9.0.0.125. My test app is attached to
this message.
Looking forward to hear from you.
Regards,
Milos
PS. Because of the file size limitation I couldn't upload a CAD file that I was using while testing but you can find it on this site: cadmapper.com/. It's a last map available for download.
ThinkGeoMapTest.zip (10.8 KB)