Hello,
I believe there is a bug in the following RhinoCommon function. ObjectTable.FindByUserString method.
The parameters I am giving the function are:
rDoc.Objects.FindByUserString(“F”, frameName, true, false, true, new ObjectEnumeratorSettings() { HiddenObjects = true }); where frameName is just a not null, not empty string.
Note that my application is multithreaded. This function is called some 100 times, in sequence, filtering a relatively large number of objects in the model.
BUT, before you say that it is due to it being multithreaded, and there are clashes as this function must be called from the UI thread, please note:
1- I am calling this function wrapped inside an action that I tell to run on Rhino UI thread using the dispatcher.
2- I added to my debug session the following code right above calling this function. The exception is never thrown, which means that the RhinoApp.InvokeRequired ALWAYS returns false
if (RhinoApp.InvokeRequired)
throw new InvalidOperationException($"The function should be running on the UI thread.");
3- I have similar functionality that is also called a number of times using my same custom wrappers to ensure that the calls are made in the Rhino thread. They never fail. These include calls to functions such as Objects.GetSelectedObjects, Objects.FindByFilter, Objects.FindByLayer, adding, removing objects. They never fail. It is exclusively this function that fails.
The errors I get are:
call stack
RhinoCore.dll!CRhinoObjectIterator::Next() Line 772
at D:\BuildAgent\work\commercial\src4\rhino4\rhino3Object.cpp(772)
rhcommon_c.dll!CRhinoDoc_LookupObjectsByUserText(const wchar_t * _key, const wchar_t * _value, bool compareCasing, bool searchGeometry, bool searchAttributes, CRhinoObjectIterator * iterator, ON_SimpleArray<CRhinoObject *> * pObjectArray) Line 1176
at D:\BuildAgent\work\commercial\src4\DotNetSDK\rhinocommon\c\rh_doc.cpp(1176)
[Managed to Native Transition]
Exception I get in Visual Studio on the C# side
Exception thrown: read access violation.
this->m_current was nullptr.