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'.
Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.
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
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
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.
Hello Robert,
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
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.Why are using a USUAL here?
Try
PRIVATE servicechannel as IWebTransferService
or
PRIVATE servicechannel as OBJECT
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
-
- Posts: 248
- Joined: Fri Oct 14, 2016 7:09 am
Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'.
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
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