Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Implementing IDisposable in a class
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01594093
Message ID:
01594327
Views:
41
You're right. And I checked, that is true for the using construct as well.

Michel should try something like
Using usingObject = New System.ServiceModel.OperationContextScope(loMyService.InnerChannel)
      loSOAPSVC.oOperationContextScope = usingObject
      .
      .
end using
I've tried this that compiles :
   Public Sub testExcel4()
        Dim testobject As New Class1

        Debug.Print(Threading.Thread.CurrentThread.CurrentCulture.DisplayName)
        Using testobject.o = New clsExcel
            Debug.Print(Threading.Thread.CurrentThread.CurrentCulture.DisplayName)
        End Using
        Debug.Print(Threading.Thread.CurrentThread.CurrentCulture.DisplayName)
    End Sub
breaks at runtime with the "Additional information: Operator '=' is not defined for 'Nothing' and type 'clsExcel'." error.

It seems that contrary to USING in C# sharp the variable that you USING must not exist outside of the USING block. It seems that it has not been implemented identically in the two languages. That's probably also why you don't need a direct access to the dispose method in VB. The object is disposed when the variable goes out of scope (i.e. in the end using).


>>Shouldn't you be doing "as" i.o. "=" ? (This is VB!)
>>
>>
>>Using loSOAPSVC.oOperationContextScope as New System.ServiceModel.OperationContextScope(loMyService.InnerChannel)
>>
>>
>>?
>
>I don't think it makes any difference with the current VB.NET since it will infer type. i.e these two are identical:
Dim a as New (x)
>Dim a = New(x)
But would only work in older version if Option Strict was Off.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform