This is a migrated thread and some comments may be shown as answers.

VB: Error with AddressOf

3 Answers 95 Views
Code Analysis
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric Schoenholzer
Top achievements
Rank 2
Eric Schoenholzer asked on 16 Dec 2009, 01:17 PM
Hi,

I use code like that in VB:

Sub x() 
   DoWsCall = AddressOf DoWsCallCommit 
End Sub 
 
Private Function DoWsCallCommit() As ShoppingCartResult 
End Function 

JustCode throws an error for "AddressOf DoWsCallCommit":

VisualBasic.Net: There is no applicable member or variable 'DoWsCallCommit'



Thanks
Eric

3 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 17 Dec 2009, 10:40 AM
Hi EricSch,

Thanks for the involvement. I try to reproduce the problem you reported with following code:

 

01.Public Class Class2
02.    Delegate Function DelegateType() As Integer
03. 
04.    Sub x()
05.        Dim DoWsCall = New DelegateType(AddressOf DoWsCallCommit)
06.    End Sub
07. 
08.    Private Function DoWsCallCommit() As Integer
09. 
10.    End Function
11.End Class

There isn't any Visual Studio or JustCode errors in it. After I remove the New DelegateType from line 5. 

JustCode found an error VisualBasic.Net: There is no applicable member or variable 'DoWsCallCommit'. Visual Studio found 'AddressOf' expression cannot be converted to 'Object' because 'Object' is not a delegate type.

Is the same happen to you?

What is the declaration of DoWsCall in your case?


All the best,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Eric Schoenholzer
Top achievements
Rank 2
answered on 17 Dec 2009, 12:40 PM

Hi,

My exact definition for the delegate is:

        Delegate Function WsCallDelegate() As ShoppingCartResult  
    
        Dim DoWsCall As WsCallDelegate 

There's no error is Visual Studio, only in JustCode.

Thanks
Eric
0
Jordan
Telerik team
answered on 19 Dec 2009, 09:23 AM
Hello EricSch,

 

We couldn't reproduce your problem. Could you send us a small sample project that demonstrates it? You can open a ticket and attach the sample project there.

 

All the best,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Code Analysis
Asked by
Eric Schoenholzer
Top achievements
Rank 2
Answers by
Jordan
Telerik team
Eric Schoenholzer
Top achievements
Rank 2
Share this question
or