AnsweredAssumed Answered

BOMTableSort.SortMethod = System.AccessViolationException

Question asked by Aaron Heathcote on Jul 25, 2016
Latest reply on Jul 27, 2016 by Aaron Heathcote

Hi all,


I wrote a macro to create a BOM and then it was then sorted. This was created as .vbproj and then I used build to create a .dll file which the macro could run from.  It worked fine on my old PC and now I've upgraded i am getting this error.


"System.AccessViolationException was unhandled by user code

  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."



This occurs on this line of code:

"BOMTableSort.SortMethod = swBomTableSortMethod_e.swBomTableSortMethod_Literal"


I have commented this line out and the rest for the macro works fine so I know it is this line which is giving me the problem.

I have also tried changing it to "BOMTableSort.SortMethod = 0" as stated here 2016 SOLIDWORKS API Help - swBomTableSortMethod_e Enumeration but still the same problem is occurring. I have also tried this on another computer and it works fine so it cant be the code, it must be something on my computer.


Any idea how I can resolve this?


Also I have noticed if I am running this macro from Microsoft Visual Studio for Applications then this macro doesn't stop debugging and I have to hit stop. This wasn't something that used to happen so any idea why that is happening as well?


Kind Regards