xsharp.eu • Incomprehensible XS1061 error
Page 1 of 1

Incomprehensible XS1061 error

Posted: Tue Oct 01, 2024 4:28 pm
by ic2
I had to make some changes in an older X#/C# DLL used by VO and unfortunately I got the usual array of errors for code which used to work a few X# version back but now not anymore. With some trial and error I could clear out most but I have no idea why this error occurs:

Code: Select all

Error	XS1061	'DotNetLibForVO.WCFService' does not contain a definition for 'remotehttp' and no accessible extension method 'remotehttp' accepting a first argument of type 'DotNetLibForVO.WCFService' could be found (are you missing a using directive or an assembly reference?)
It's in the line of code and 'remotehttp', which is not found according to the error, is a member of an enum which shows both as tooltip and via Peek definition (on WCFConnectionType). The Enum was in another .prg but moving it did not clear the error. Nor did a complete solution clear & rebuild. See also the picture:
WCFConnectionType.jpg

Code: Select all

service := WCFConnectionType:Get_Channel(WCFConnectionType.remotehttp, cRemoteAdr)
How can I get rid this formerly non existing error?

One small other thing - I did solve it but makes me wonder why this could only be done with with right mouse, Properties on the project, Language then Allow Dot for instance members

Code: Select all

nRowCount:=oRange:Rows.Count
gives Error XS9112 Can't access the instance member 'Microsoft.Office.Interop.Excel.Range.Count' with the DOT operator '.'.

but

Code: Select all

nRowCount:=oRange.Rows.Count
gives Error XS0118 'oRange' is a variable but is used like a type

I should be able to get this compiling either way, without compiler options, I'd say?

Dick

Re: Incomprehensible XS1061 error

Posted: Tue Oct 01, 2024 8:25 pm
by robert
Dick,

You mention
an older X#/C# DL
I don't understand that. The DLL is either X# or C#.

You are not showing all the code. But in the code that you show I see that you have a local or field with the name "WCFConnectionType".
Most likely, the compiler finds both the local/field and the enum and gets confused.
You can solve that by writing

Code: Select all

service := WCFConnectionType:Get_Channel(DotNetLibForVO.WCFConnectionType.remotehttp, cRemoteAdr)

Btw the line

Code: Select all

nRowCount:=oRange.Rows.Count
will only compile if you have enabled the "Allow Dot for instance members" option, because Rows is an instance property of oRange, and Count is an instance property of the Rows collection.





Robert

Re: Incomprehensible XS1061 error

Posted: Wed Oct 02, 2024 9:51 am
by ic2
Hello Robert,
robert wrote: Tue Oct 01, 2024 8:25 pm I don't understand that. The DLL is either X# or C#.
It's one solution with a few X# projects included and 1 C# project. That compiles to one DLL.That I find one of the advantages of .Net, that you can easily mix languages.
robert wrote: Tue Oct 01, 2024 8:25 pm You are not showing all the code. But in the code that you show I see that you have a local or field with the name "WCFConnectionType".
Most likely, the compiler finds both the local/field and the enum and gets confused.
You can solve that by writing

Code: Select all

service := WCFConnectionType:Get_Channel(DotNetLibForVO.WCFConnectionType.remotehttp, cRemoteAdr)
Indeed! I totally overlooked the fact that I assigned WCFService() to a local with the same name. No idea why (it's derived from C# code years ago) but your solution solves it, thanks a lot! Apparently earlier X# versions did make the right WCFConnectionType choice coincidentally (probably just with a warning).
robert wrote: Tue Oct 01, 2024 8:25 pm Btw the line

Code: Select all

nRowCount:=oRange.Rows.Count
will only compile if you have enabled the "Allow Dot for instance members" option, because Rows is an instance property of oRange, and Count is an instance property of the Rows collection.
It works well with this compiler option; I understand from your answer that I could do without, should I wish so, by breaking this line up in 2 different lines.

Dick



Robert
[/quote]

Re: Incomprehensible XS1061 error

Posted: Wed Oct 02, 2024 5:44 pm
by FFF
ic2 wrote: Wed Oct 02, 2024 9:51 am It works well with this compiler option; I understand from your answer that I could do without, should I wish so, by breaking this line up in 2 different lines.
AFAIS, no need for breaking. Replacing both dots with colons should do it.

Re: Incomprehensible XS1061 error

Posted: Thu Oct 03, 2024 7:38 pm
by ic2
Hello Karl,

Indeed, nRowCount:=oRange:Rows:Count works without the setting, thanks.

Often it's a bit of VO (or maybe Vulcan) created code with or without something more in this program. So instead of thinking what I am looking at (instance property etc) and what I should use I let the compiler decide for me ;)

Dick

Re: Incomprehensible XS1061 error

Posted: Thu Oct 03, 2024 8:11 pm
by FFF
Yeah - reading isn't guaranteed to equal understanding, what one has read :)
(Otherwise round, similiar - i know, there's a thing "class variable" - but can't remember how this works and seem to be unable to find the right thing to use as search in the help...)

Re: Incomprehensible XS1061 error

Posted: Thu Oct 03, 2024 11:20 pm
by Chris
Hi Karl,

"Class variable" is another name for STATIC fields of a class (STATIC EXPORT, STATIC PROTECT etc). Also STATIC METHOD is often referred to as "class function".

Re: Incomprehensible XS1061 error

Posted: Fri Oct 04, 2024 7:25 am
by FFF
"Static" - that was the key i needed, thank you!