Hi there everyone,
I’m not really a developer, I learn things as I go, and I think that’s why I had to completely reinstall SolidWorks 3 times in the last 3 months. I’m using CadBooster.SolidDNA librarys to build my apps. To achive some funcionalities I have to use “Unsfe objects”. I’m also more familiar with them from the VBA macros.
Code example:
//Globals.swModel → SolidDNA model object
ModelDoc2 swModel = Globals.swModel.UnsafeObject;
IFeature swMateFeature = null;
IFeature swMateSubFeature = null;
var swFeat = swModel.IFirstFeature();
while (swFeat != null)
{
if (swFeat.Name == "Mates")
{
swMateFeature = swFeat;
}
swFeat = swFeat.IGetNextFeature();
}
swMateSubFeature = (IFeature)swMateFeature.GetFirstSubFeature();
...
swModel = null;
swFeat = null;
swMateFeature = null;
swMateSubFeature = null;
When working with unsafe object, the description clearly says to handle the disposal. From the AngelSix videos, I remember that he used Marshal.ReleaseComObject(Object), but some Google hits say that this is not required and setting the variables to null is enough.
My question is, what is the correct way of disposing of unsafe objects? and what happens if the code fails before you manage to dispose?
Has anyone else managed to stop Solidworks from working this way? Mine gets stuck on the splash screen, saying “verifying license”.
Thank you.