First, setting the model path and turning on Smart Labels repeatedly will cause an exception after 3-5 repetitions. I was able to reproduce this in the Smart Labels sample using the Cow.mdg model.
1) Open model in Smart Labels sample (I used Cow.mdg)
2) Select Labels -> Auto Generate
3) Repeat until crash
System.AccessViolationException
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=mscorlib
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at KernCADnet._DKernCADnet.set_ModelPath(String )
at AxKernCADnet.AxKernCADnet.set_ModelPath(String value)
at SmartLabels.SmartLabelsForm.OnFileOpen(Object sender, EventArgs e) in C:\Projects\DGKernel_6_2\Samples\NET\C#\Labels\SmartLabels\SmartLabelsForm.cs:line 97
=====================================================
Second, using two instances of AxKernCADnet will cause a crash after enabling Smart Labels on both of them then calling UpdateView() on both of them.
I use two AxKernCADnet instances, one to display the front of the model and one for the back
Code: Select all
axKernCADnetFront.ModelPath = modelPath;
axKernCADnetBack.ModelPath = modelPath;
Code: Select all
CreateLabelsHelper(axKernCADnetFront.GetView() as IView_DG);
CreateLabelsHelper(axKernCADnetBack.GetView() as IView_DG);
private void CreateLabelsHelper(IView_DG view)
{
if (view != null)
{
ISmartLabelManager_KC labelManager = (ISmartLabelManager_KC)view;
IDynamicScreenItemManager_KC dynamicManager = (IDynamicScreenItemManager_KC)view;
dynamicManager.Enable(true);
labelManager.SetStringSource(EStringSource.eStringSourceLayerName);
labelManager.CreateLabelsAutomatic();
}
}
Code: Select all
axKernCADnetFront.UpdateView();
axKernCADnetBack.UpdateView(); // <- crash here
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=mscorlib
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at KernCADnet._DKernCADnet.UpdateView()
at AxKernCADnet.AxKernCADnet.UpdateView()