4 Replies Latest reply on Jul 1, 2013 9:22 AM by Artem Taturevych

    The thread tried to read from or write to a virtual address for which it does not have the appropriate access

    Joseph Regan

      Good Afternoon,

      I am trying to create a vb.net program that acts as an addin to solidworks.  What this program does is draw some things on a 2D Drawing, and gets some values from the drawing.  All this is done successfully.  Then, the interaction with the solidworks drawing is complete and the program proceeds onto the next screen. 

       

      When I finish the interaction with solidworks, i use:

       

      System.Runtime.InteropServices.

      Marshal.ReleaseComObject(userAddin)

       

       

      Then I open up a new form in vb.net to do some processing with this data.  However, sometimes this crashes solidworks.  Solidworks will crash and then I get the error

      The thread tried to read from or write to a virtual address for which it does not have the appropriate access

       

       

       

      It seems that any runtime error in vb.net will crash solidworks.  The error I get sometimes with 

      System.Runtime.InteropServices.Marshal.ReleaseComObject(userAddin)

      is The object's type must be __ComObject or derived from __ComObject.  It seems approximately 1/10 times I will get this error, which is probably why solidworks is crashing.  Any advice on how to dispose the connection to solidworks to proceed with further processing?

      Thank you!