Layerform Exception
Moderators: SDS, support, admin
Layerform Exception
Hello,
when I'm adding some Layers to my CadEditorControl see all my layers and the layer "0".
When I click on the layer "0" a "{"Object reference not set to an instance of an object."} exception is thrown (stack trace below).
When I remove the "0" layer from the LayerForm.LayerList the first layer throws the same exception. As I figured out I can't access the event when the layers are seletced inside the LayerForm.
When I'm createing a new Image, I'm adding 2 additional Layers: Picture(2)/ Drawing(3). After adding some content the slection of the layers 2/3 works, if empty the exception is also thrown.
My Code for adding the layers is:
Is my code correct?
Thank you,
Roman
Stack Trace:
at System.Collections.Generic.List`1.get_Item(Int32 index)
at CADImport.CADEntityCollection.get_Item(Int32 index)
at CADImport.FaceModule.CADImportFace.SelectLayer(Int32 ind, CADImage img)
at CADImport.CADImportControls.CADEditorControl.(ArrayList , ListEventSelectArgs )
at CADImport.FaceModule.CADListView.OnSelectItem(ArrayList items, ListEventSelectArgs e)
at CADImport.FaceModule.CADListView.(Int32 )
at CADImport.FaceModule.CADListView.SelectCells(Int32 x, Int32 y, Boolean fullItem)
at CADImport.FaceModule.CADListView.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at CADImport.FaceModule.CADListView.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.Form.ShowDialog(IWin32Window owner)
at CADImport.CADImportControls.CADEditorControl.(Object , ToolBarButtonClickEventArgs )
at System.Windows.Forms.ToolBarButtonClickEventHandler.Invoke(Object sender, ToolBarButtonClickEventArgs e)
at System.Windows.Forms.ToolBar.WmReflectCommand(Message& m)
at System.Windows.Forms.ToolBar.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at CADImport.CADImportControls.CADEditorControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolBar.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 Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2.Start()
at Microsoft.Practices.CompositeUI.CabApplication`1.Run()
at Elitec.Infrastructure.Shell.ShellApplication.RunInDebugMode() in D:\Projects\Elitec Software\Source\Infrastructure\Shell\ShellApplication.cs:line 56
at Elitec.Infrastructure.Shell.ShellApplication.Main() in D:\Projects\Elitec Software\Source\Infrastructure\Shell\ShellApplication.cs:line 47
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
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()
when I'm adding some Layers to my CadEditorControl see all my layers and the layer "0".
When I click on the layer "0" a "{"Object reference not set to an instance of an object."} exception is thrown (stack trace below).
When I remove the "0" layer from the LayerForm.LayerList the first layer throws the same exception. As I figured out I can't access the event when the layers are seletced inside the LayerForm.
When I'm createing a new Image, I'm adding 2 additional Layers: Picture(2)/ Drawing(3). After adding some content the slection of the layers 2/3 works, if empty the exception is also thrown.
My Code for adding the layers is:
Code: Select all
private CADLayer CreateLayers()
{
CADLayer picLayer = CreateLayer("Picture");
CADLayer layer = CreateLayer("Drawing");
layer.IsPlotting = true;
_currentLayer = layer;
return picLayer;
}
private CADLayer CreateLayer(string name)
{
CADConverter converter = ImageConverter();
CADLayer layer = new CADLayer();
layer.Name = name;
layer.Color = Color.RoyalBlue;
layer.Visibility = true;
converter.Layers.Add(layer);
converter.OnCreate(layer);
converter.Loads(layer);
AddRecordToLayerList(layer.Name, layer.Color, true, false);
return layer;
}
Thank you,
Roman
Stack Trace:
at System.Collections.Generic.List`1.get_Item(Int32 index)
at CADImport.CADEntityCollection.get_Item(Int32 index)
at CADImport.FaceModule.CADImportFace.SelectLayer(Int32 ind, CADImage img)
at CADImport.CADImportControls.CADEditorControl.(ArrayList , ListEventSelectArgs )
at CADImport.FaceModule.CADListView.OnSelectItem(ArrayList items, ListEventSelectArgs e)
at CADImport.FaceModule.CADListView.(Int32 )
at CADImport.FaceModule.CADListView.SelectCells(Int32 x, Int32 y, Boolean fullItem)
at CADImport.FaceModule.CADListView.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at CADImport.FaceModule.CADListView.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.Form.ShowDialog(IWin32Window owner)
at CADImport.CADImportControls.CADEditorControl.(Object , ToolBarButtonClickEventArgs )
at System.Windows.Forms.ToolBarButtonClickEventHandler.Invoke(Object sender, ToolBarButtonClickEventArgs e)
at System.Windows.Forms.ToolBar.WmReflectCommand(Message& m)
at System.Windows.Forms.ToolBar.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at CADImport.CADImportControls.CADEditorControl.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolBar.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 Microsoft.Practices.CompositeUI.WinForms.FormShellApplication`2.Start()
at Microsoft.Practices.CompositeUI.CabApplication`1.Run()
at Elitec.Infrastructure.Shell.ShellApplication.RunInDebugMode() in D:\Projects\Elitec Software\Source\Infrastructure\Shell\ShellApplication.cs:line 56
at Elitec.Infrastructure.Shell.ShellApplication.Main() in D:\Projects\Elitec Software\Source\Infrastructure\Shell\ShellApplication.cs:line 47
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
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()
Re: Layerform Exception
Hello Roman.
The code to create a layer is correct. However CADEditorControl class includes own inner CADImage and LayerForm objects. The code must be adapted to CADEditorControl.LayerForm and CADEditorControl.Image members. Otherwise you will get exceptions.
Alexander.
The code to create a layer is correct. However CADEditorControl class includes own inner CADImage and LayerForm objects. The code must be adapted to CADEditorControl.LayerForm and CADEditorControl.Image members. Otherwise you will get exceptions.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Layerform Exception
Hello,
I got the reason for the exception:
If the layer "0" is selected (with default settings) a "null reference exception" (see above) is thrown.
The reason is quite simple. The layer "0" has no color by default and so the exception is thrown. If I assign a color to the "0" layer everything seems to work....
I got the reason for the exception:
If the layer "0" is selected (with default settings) a "null reference exception" (see above) is thrown.
The reason is quite simple. The layer "0" has no color by default and so the exception is thrown. If I assign a color to the "0" layer everything seems to work....
Re: Layerform Exception
Hello.
The layer "0" must have default color specified if CADImage created correctly. Which code you use to create new image?
Alexander.
The layer "0" must have default color specified if CADImage created correctly. Which code you use to create new image?
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Layerform Exception
I'using
cadEditorControl1.CreateNewImage();
which doesn't add color(?). I'm using the Windows Forms CadEditorControl.
I also found another issue:
When a layer is added with the given code I can access the layer by
CADImage.Converter.Layers[index] and
CADImgage.Converter.LayerByName("name").
When calling LayerByName the instance of the layer is not the same as the one I get from the instance.
As a result of this adding a CADEntity.Layer = CADConverter.Layers[2] (name = "myLayer") is not the same as CADConverter.LayerByName("myLayer")....
I tested in Debug mode and Layer[2] == LayerByName("myLayer") was false.
Roman
cadEditorControl1.CreateNewImage();
which doesn't add color(?). I'm using the Windows Forms CadEditorControl.
I also found another issue:
When a layer is added with the given code I can access the layer by
CADImage.Converter.Layers[index] and
CADImgage.Converter.LayerByName("name").
When calling LayerByName the instance of the layer is not the same as the one I get from the instance.
As a result of this adding a CADEntity.Layer = CADConverter.Layers[2] (name = "myLayer") is not the same as CADConverter.LayerByName("myLayer")....
I tested in Debug mode and Layer[2] == LayerByName("myLayer") was false.
Roman
Re: Layerform Exception
Hello Roman.
CADEditorControl.CreateNewImage method sets a color value for the layer "0". Please specify the version number of the CADImport.dll assembly that you use.
Alexander.
CADEditorControl.CreateNewImage method sets a color value for the layer "0". Please specify the version number of the CADImport.dll assembly that you use.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: Layerform Exception
Hello,
assembly Version: 8.1.0.20817
assembly Version: 8.1.0.20817
Re: Layerform Exception
Hello.
The layer "0" color set correctly within CADEditorControl.CreateNewImage method using library version 8.1.0.20817. Please check the color value in debug mode. We have also found a possible cause of the error. By the way have you called CADEditorControl.EntityPropertyGrid.Dispose method? Entity property grid used to display entities data. Selecting any entity, particularly a layer, when EntityPropertyGrid is disposed will result in NullReferenceException. You can specify the property grid invisibility if you don't need it.
We have also found mentioned problem with method LayerByName. We will consider it.
Alexander.
The layer "0" color set correctly within CADEditorControl.CreateNewImage method using library version 8.1.0.20817. Please check the color value in debug mode. We have also found a possible cause of the error. By the way have you called CADEditorControl.EntityPropertyGrid.Dispose method? Entity property grid used to display entities data. Selecting any entity, particularly a layer, when EntityPropertyGrid is disposed will result in NullReferenceException. You can specify the property grid invisibility if you don't need it.
We have also found mentioned problem with method LayerByName. We will consider it.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support