fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

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

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'. 1 year 5 months ago #1

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

Please Log in or Create an account to join the conversation.

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'. 1 year 5 months ago #2

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
XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.

Please Log in or Create an account to join the conversation.

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'. 1 year 5 months ago #3

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

Please Log in or Create an account to join the conversation.

Error XS026 Cannot implicitly convert type .... to to 'Vulcan.__Usual'. 1 year 5 months ago #4

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

Please Log in or Create an account to join the conversation.

  • Page:
  • 1