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

0 Members and 1 Guest are viewing this topic.

Sieu khung khiep

  • Mosquito
  • Posts: 15
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 - vb.net: [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 »

VVeli

  • Newt
  • Posts: 27
Re: Problem Object is never disposed in Vsto 2019
« Reply #1 on: May 08, 2020, 07:20:11 AM »
Can you remove marks away?
Br. Veli
« Last Edit: May 08, 2020, 07:27:01 AM by VVeli »

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Problem Object is never disposed in Vsto 2019
« Reply #2 on: May 08, 2020, 12:42:26 PM »
I suspect the code isn't the problem, but rather the compiler isn't accurately understanding what is going on ..

What happens if you do this?

Code - vb.net: [Select]
  1. Private Sub SetStoredRotation(ByVal obj As DBObject, ByVal rotation As Double)
  2.     AddRegAppTableRecord(kRegAppName)
  3.     Using rb As ResultBuffer = IIf(IsNothing(obj.XData), New ResultBuffer(), obj.XData)
  4.         rb.Add(New TypedValue(kAppCode, kRegAppName))
  5.         rb.Add(New TypedValue(kRotCode, rotation))
  6.         obj.XData = rb
  7.     End Using
  8. End Sub
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie