Skip to main content

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
I just copied your example into a new project and it works fine.
I am using Visual COBOL V4.0 Patch Update 3 for Visual Studio 2017.

What version are you using?

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
Micro Focus Visual COBOL 4.0 Version 4.0.00243.

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
Visual Studio 2017

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
That is the same version I am using.
I just created a new managed console application and copied the following into the default program.
Does this work for you or do you get the same error?

program-id. Program1 as "testextensions.Program1".

data division.
working-storage section.

procedure division.
declare a as string = "Mary"
declare b as binary-long = a::CountWords

goback.

end program Program1.

class-id Extensions static.
Method-id CountWords(str as string) returning result as binary-long extension static.
declare #words as string occurs any = str::Split(' ')
set result to size of #words
end method.
End class.

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
I will test that and see. Currently I am developing a managed windows form application and trying to use extension methods per my previous post.

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
That worked in a console application, but is still not working in my managed windows form application. I found some old code I developed using Visual Studio 2015 Visual Cobol and a windows form application where the extension methods worked and were recognized.

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
It would probably be best for you to open up a support incident with Customer Support and I could take a look at what you are doing. You could put my name in the description and that way it will be routed to me.

 Are extension methods still recognized in the latest visual cobol for .net?  I have a very simple ext method I am trying out and it does not seem to be recognized.  I keep getting the error Undefined Error Contact Tech Support.  I have a static extensions class like this.  

class-id Extensions static.

 

Method-id CountWords(str as string) returning result as binary-long extension static.
    declare #words as string occurs any = str::Split(' ')
    set result to size of #words
end method.
End class.

 

 

Then my calling method is in another class like this.

Method-id SomeMethod()

declare a as string = "Mary"
declare b as binary-long = a::CountWords

End method.

 

Intellisense does not recognize CountWords as an extension and I get the error noted above.


#VisualCOBOL
OK. Thanks Chris. I will do that shortly.