I stripped my addin down to include this line in ConnectToSw()
<p>_swApplication.ActiveDocChangeNotify += new DSldWorksEvents_ActiveDocChangeNotifyEventHandler(_swApplication_ActiveDocChangeNotify);</p>
When I compile the addin for AnyCpu and run on Win7 x64, SW64 2010 SP0.0 generates a crash report (Windows Error Reporting in Event Viewer\\Application) when exiting.
Does this happen to you ?
<p>Fault bucket 8825956, type 4<br>Event Name: APPCRASH<br>Response: Not available<br>Cab Id: 0<br><br>Problem signature:<br>P1: sldworks.exe<br>P2: 18.0.0.5035<br>P3: 4ad6bf42<br>P4: ntdll.dll<br>P5: 6.1.7600.16385<br>P6: 4a5be02b<br>P7: c0000005<br>P8: 000000000002504f<br>P9: <br>P10:</p>
Adding these two lines to DisconnectSW() seems to help. I am surprised that SW doesn't die when the Addin is unloaded manually ...
<p>Marshal.ReleaseComObject(_swApplication);<br><br> GC.WaitForPendingFinalizers();</p>SolidworksApi macros

Hi,
having same kind of problem, but the dll is sldappu.dll. I'll try to add same stuff to DisconnectSW() and let's see what happens...
There were a couple issues with SLDWORKS not unloading on exit.
* Not releasing all references with Marshal.ReleaseComObject
* Not unregistering each event
"were"... so you mean that sp4.0 should work properly? just tested shortly with sp2.1, added lines above to my add-ins, but still getting crash on exit (sldappu.dll)
This was happening until I released all my RCWs, which I must have missed before. And of course, once you tie and event handler, you'll have to untie it before you disconnect.
This was probably happening in Win XP too but that windows error reporting component isn't in XP.
I am running into other issues with Win7 and .NET4 though.
Are you releasing all the COM object you create?
ps. I remember reading somewhere that at least two GC passes are required to clear RCWs off the heap.