xsharp.eu • Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.
Page 1 of 1

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.

Posted: Tue Oct 17, 2017 10:06 pm
by ic2
I am translating a Vulcan program handling WCF to X#, which was originally translated from C#.

This is part of the working Vulcan code:

PRIVATE servicechannel AS USUAL
....
SELF:servicechannel := channel:CreateChannel()
RETURN SELF:servicechannel
On the SELF:servicechannel := channel:CreateChannel() line I get

Error XS0266 Cannot implicitly convert type 'WCFInterfaces.IWebTransferService' to 'Vulcan.__Usual'.

The original C# code looks as follows:
private T servicechannel;
servicechannel = channel.CreateChannel();
return servicechannel;

XS0026 says:
Keyword 'SELF' is not valid in a static property, static method, or static field initializer
but I am not sure what I should do with this. I seem to remember Chris has replied me earlier about some issue with 'STATIC' but I can't find it back.

Dick

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.

Posted: Tue Oct 17, 2017 10:23 pm
by robert
Dick,

Why are using a USUAL here?
Try
PRIVATE servicechannel as IWebTransferService

or

PRIVATE servicechannel as OBJECT

If it has to be a USUAL then you need to add a cast (for now)

SELF:servicechannel := (OBJECT) channel:CreateChannel()

This is something that we will fix in one of the next builds.

I think the original C# code was using a generic parameter T. We support that as well. So if you show the original C# code we might even give a better solution.

Robert

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.

Posted: Wed Oct 18, 2017 8:52 am
by ic2
Hello Robert,
Why are using a USUAL here?
Try
PRIVATE servicechannel as IWebTransferService
or
PRIVATE servicechannel as OBJECT
I tried the first earlier and got the same error. USUAL was (in Vulcan) after trial& error the way I got it working but here OBJECT helps to get rid of the error, thanks for that.

If it all works as it did in Vulcan (I expect so) I leave the code like that. But it's good to know that X# is so much closer to C# - I think it would have been much easier to convert this C# code to X# than it was to convert it to Vulcan. This WCF code is a bit of a black box for me which makes it more difficult to convert.

Dick

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.

Posted: Wed Oct 18, 2017 9:06 am
by NickFriend
Hi Dick,

If you're trying to create a channel for a WCF service, you could use ChannelFactory. In C# it would be something like

T servicechannel;
ChannelFactory<T> channel = new ChannelFactory<T>(binding, address);
servicechannel = channel.CreateChannel();

where T is the WCF service interface that you're trying to access.

HTH

Nick