Last post Jul 08, 2014 09:07 AM by Rob-B
Jul 08, 2014 06:39 AM|Rob-B|LINK
The following code is an extract from a working VB.net project that connects to an established WCF service
' Start a call to the Middleware service' "Middleware" is the Namespace given when adding the reference
Dim M As New Middleware.CustomerIdentificationServiceClient
' Create a new Customer class to hold the result
Dim Customer As New Middleware.Customer
' Call the service
Customer = M.GetCustomerInformation("123456") 'Customer Number
I now need to do a similar task but from a C# project, and I'm getting convert errors in Visual Studio. I initially tried an online service to convert the VB to C but with little success. I've looked a lot into this online but can't find the answer, maybe
not searching for the right things?
Using Middleware;// Start a call to the Middleware service
// Reference are not qualified as Using above pulls them in.
CustomerIdentificationServiceClient M = new CustomerIdentificationServiceClient();
// Create a new UKSL Agreement reference to hold the result
Customer C = new Customer();
C = M.GetCustomerInformation("123456"); //The customer number
No matter what I try in the C# project I get the following error (highlighted against the last line in the C# code):
Cannot implicitly convert type 'MyProject.Middleware.Customer' to 'MyProject.Middleware.Customer [C:\Path\To\Code\MyProject\Project\MyProject\Service References\Middleware\Reference.cs(20)]' C:\Path\To\Code\MyProject\Project\MyProject\BLL\AuthorisationInformation.cs 48 20 MyProject
Really appreciate any thoughts on this.
A few extra notes, I've clearly changed some name/references in the code, but I believe the fundamental points still stand. Secondly C# is not my strong point at all, but very comfortable with VB.Net.
Jul 08, 2014 06:49 AM|Dharmesh.Kotadiya|LINK
try like this
C = (Customer)M.GetCustomerInformation("123456");
Jul 08, 2014 09:07 AM|Rob-B|LINK
Excellent, the compiler isn't complaining any more, haven't got enough code done to actually attempt to run it - but we are looking good!
Thanks very much for the direction.