Author Topic: Problem Object is never disposed in Vsto 2019  (Read 230 times)

0 Members and 1 Guest are viewing this topic.

Sieu khung khiep

  • Mosquito
  • Posts: 13
Problem Object is never disposed in Vsto 2019
« on: November 21, 2019, 12:46:33 AM »
Hi, as far as I know .Net 2020 Objarx Sdk is compatible with Vsto2017, but currently my habit is to use on Vsto2019, it still works normally with my cad2020 version except some pretty annoying notifications and I haven't yet know how to handle them (no message appear on vsto2017 andalso no message with Excel vsto 2019 but only Cad ). This is the code I come across (code written a long time ago) but I'm still here reading them because I'm newer:

Code - [Select]
  1.        Private Sub SetStoredRotation(ByVal obj As DBObject, ByVal rotation As Double)
  2.             AddRegAppTableRecord(kRegAppName)
  3.             Dim rb As ResultBuffer = obj.XData
  4.             If rb Is Nothing Then
  5.                [u]rb = New ResultBuffer[/u](New TypedValue(kAppCode, kRegAppName), New TypedValue(kRotCode, rotation))
  6.             Else
  7.                 rb.Add(New TypedValue(kAppCode, kRegAppName))
  8.                 rb.Add(New TypedValue(kRotCode, rotation))
  9.             End If
  10.             obj.XData = rb
  11.             rb.Dispose()
  12.         End Sub

The error is: Disposable object created by 'New ResultBuffer... is never disposed

I am stuck using [using / try catch] and I'm not sure why rb.dispose doesn't work (other vsto19 project without Cad still work normally)
Can I handle this error without suppress messages and without declaring other object types?
Thanks a lot!
« Last Edit: November 21, 2019, 09:22:30 AM by Sieu khung khiep »