WCF Data Service reference in WPF Project in VS2017
Asked Answered
P

2

6

I'm having issues adding a service reference to my WPF project in VS2017. The service itself is a WCF Data Service using EntityFramework (EntityFrameworkDataService). In VS2013 that I was using before, I didn't have any issues adding services to my WPF project. I upgraded to VS2017 last month, and recently made some changes to the WCF service and needed to refresh the reference in my WPF project. I couldn't seem to get it to refresh so I deleted the reference and started trying to re-add the reference and now I'm greeted with this error message:

The specified OData API cannot be added because OData APIs are now only supported with Connected Services.

For more information, please see: https://aka.ms/odatavsclientguidance

That provided link does not have any info regarding VS2017 setups. It recommends to use the 'OData Connected Service' extension but that extension does not support VS2017 (tried it but got a "not compatible" message). I also found the 'VS WCF Connected Service' extension for VS2017, but it doesn't appear to support WPF projects (or atleast I couldn't figure it out).

Has anyone ran into this issue with adding a WCF Data Service reference to a WPF project? Any other suggestions that I could try?

Prebend answered 5/4, 2017 at 17:5 Comment(1)
Have you found any solution to this yet? I'm having the same problem.Acalia
B
5

I typically generate my clients via the DataSvcUtil.exe which is part of the .net framework

e.g.

"%windir%\Microsoft.NET\Framework\v4.0.30319\DataSvcUtil.exe" /dataservicecollection /version:2.0 /language:CSharp /out:c:\temp\DataService.cs /uri:http://localhost:16584/DataService/

The MSDN docs: https://msdn.microsoft.com/en-us/library/ee383989(v=vs.110).aspx

Blandishment answered 13/4, 2017 at 19:28 Comment(0)
E
4

As TGRA so eloquently stated, the best bet for VS2017 at time of writing is to use the dataserviceutil.exe. To make things simpler for myself I do the following:

  1. In File Explorer, navigate to the datasvcutil.exe using the path as follows: %windir%\Microsoft.NET\{{YOUR_PROCESSOR_ARCHITECTURE}}\{{YOUR_FRAMEWORKVERSION}}

  2. Hold shift and right-click. Select Open Commandwindow here (or command prompt if you prefer.

  3. Now execute a datasvcutil.exe command like so for C#: datasvcutil /language:Csharp /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.cs /uri:{{URL_TO_SERVICE}}.svc

  4. OR execute a datasvcutil.exe command like so for Visual Basic: datasvcutil /language:VB /out:{{PATH_TO_PROJECT}}/{{SERVICE_NAME}}.VB /uri:{{URL_TO_SERVICE}}.svc

And voila, you're done.

Estriol answered 29/5, 2017 at 14:4 Comment(2)
I gave the answer to TGRA since it is the same solution and the first one to answer. But thanks for the extra details.Prebend
After generation of this file how/where to use it?Kenlee

© 2022 - 2024 — McMap. All rights reserved.