Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding OData Connected Service to the project failed: Value cannot be null #64

Closed
rendmath opened this issue Sep 4, 2017 · 33 comments
Closed
Labels

Comments

@rendmath
Copy link

rendmath commented Sep 4, 2017

We are converting a VS2015 solution using WCF Data Services to VS2017. The web service itself seems to be working fine, but the database model has evolved and we now need to update our OData service reference.

Visual Studio displays an error message, warning us that "The specified OData API cannot be updated because OData APIs are now only supported with Connected Services". We downloaded the connected services extensions available here : https://marketplace.visualstudio.com/items?itemName=laylaliu.ODataConnectedService.

But we can't seem to generate a new OData client for any projet, even a new simple console application. The "OData Connected Service" wizard invariably fails in the "Finish" step with this error message: "Adding OData Connected Service to the project failed: Value cannot be null. Parameter name: path1".

OData Connected Service version: 0.3.0
Visual Studio version: 2017 Enterprise 15.3.3
.NET Framework version: 4.6.1
WCF Data Services versions (server-side):

  • Microsoft.Data.Edm: 5.6.0
  • Microsoft.Data.OData: 5.6.0
  • Microsoft.Data.Services: 5.6.0
  • Microsoft.Data.Services.Client: 5.6.0
  • Microsoft.OData.EntityFrameworkProvider: 1.0.0-alpha2
  • System.Spatial: 5.6.0

Here is the $metadata for our service:
$metadata.zip

@rendmath
Copy link
Author

rendmath commented Sep 4, 2017

We have updated our NuGet packages to the latest versions available, but the problem stays the same:
WCF Data Services versions (server-side):

  • Microsoft.Data.Edm: 5.8.1
  • Microsoft.Data.OData: 5.8.1
  • Microsoft.Data.Services: 5.8.1
  • Microsoft.Data.Services.Client: 5.8.1
  • Microsoft.OData.EntityFrameworkProvider: 1.0.0-beta2
  • System.Spatial: 5.8.1
  • Entity Framework: 6.1.3

@black78
Copy link

black78 commented Sep 7, 2017

VS 2017 15.3.3 same problem:
Adding Nuget Packages
Error:Adding OData Connected Service to the project failed: Value cannot be null.
Parameter name: path1

@robward-ms robward-ms added the P2 label Sep 11, 2017
@nla-brandonjames
Copy link

I also get this error. This is after applying the fix @Gabee01 implemented in PR #67 in order to get the metadata without credentials. This is a continuation of issue #56. It also happens if I get the definitions from an edmx file.

@nla-brandonjames
Copy link

I ran this project on debug and I found that it pulls null at Line 31 on V3CodeGenDescriptor.cs. The path is referring to the WCF install location.

@nla-brandonjames
Copy link

I had to dig through my Windows registry to find out what the issue was. So, CodeGeneratorUtils accesses the Windows Registry to try to figure out where the install location of WCF Services is. On my machine, neither the "SOFTWARE\Wow6432Node\Microsoft\Microsoft WCF Data Services\VS 2014 Tooling\" nor the "SOFTWARE\Microsoft\Microsoft WCF Data Services\VS 2014 Tooling\" path existed in the registry. So I found out the key that referred to the actual install location of WCF Data Services on my machine. It was "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services\5.6\". But I couldn't figure out how to get the code to read the registry path so I just hard-coded the value of InstallLocation from that myself so code gen would work. It was "C:\Program Files (x86)\Microsoft WCF Data Services\5.6". Hopefully you guys can find a more elegant fix for this!

@AlanWong-MS
Copy link
Contributor

@nla-brandonjames we're trying to consolidate all the issues people are coming across on this project. After you modified the registry, have you come across new issues?

@nla-brandonjames
Copy link

@AlanWong-MS I did not modify the registry, I just read it to try and figure out what value project was trying to access. I don't have any more issues to report.

@AlanWong-MS
Copy link
Contributor

@nla-brandonjames ah, I reread what you wrote and I see what you did. Okay, thanks for the feedback! This will help us determine the scope of our issues.

@AlanWong-MS
Copy link
Contributor

@rendmath , @black78
Does the registry path workaround help?

@layos
Copy link

layos commented Sep 20, 2017

My five cents to discussion. We had the same issue in a shared project on TFS. A colleague of mine got this error but I didn't. The difference between us is that he has Visual Studio installed in italian. I don't now if it matters. But it is just an additional info.

@RayCon-LP
Copy link

I've update a WebAPI project with OData from VS2013 to VS2017, installed the OData Connected Services and encountered the same issue. Tried installing VS2017 on a newly built machine and had the same problem. As mentioned by @nla-brandonjames the WCF Data Services registry settings are missing along with the installation files.

Had a look at a VM with VS2015 and the files and registry entries are intact.

After installing VS2015 on the project machine, I could generate the reference file. Remove VS2015 and the registry and installation files were removed and back to the issue.

I'm not sure where VS2017 puts the WCF files, as that option was checked in the installation.

@AlanWong-MS, you should try having an installation of VS2017 only and a WebAPI project with OData and try adding the connected service.

@mohsenno1
Copy link
Contributor

I have the same problem.
Visual Studio 2017 Community 15.2.

I tried to debug it using another instance of visual studio. I got this error:

Could not load file or assembly 'Microsoft.VisualStudio.ConnectedServices.Package2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

And, Right after it I got:

"Value cannot be null.\r\nParameter name: path1"

@nla-brandonjames Can you please explain how did you solve the problem in your case? How did you hard-coded InstallLocation into the code? Did you compile the source by yourself? I

@mohsenno1
Copy link
Contributor

I found a temporary solution:
Go to registry:
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services]

I my case I found VS 2010 Tooling key.
I made a duplicate of that key and renamed it to VS 2014 Tooling.

Now it's working fine.

But this problem can be solved easily by changing the source code:

In V3CodeGenDescriptor.cs#L32 just needs to be checked that if string.IsNullOrEmpty(wcfDSInstallLocation) and if it is then jump to the else statement.

And this will fix the bug.

@AlanWong-MS
Copy link
Contributor

@mohsenno1 can you please open a PR with your proposed fix?

mohsenno1 added a commit to mohsenno1/lab that referenced this issue Sep 26, 2017
@AlanWong-MS
Copy link
Contributor

Summarizing issue for bookkeeping:

As others have been seeing, the exact method that takes a look at the registry is GetWCFDSInstallLocation() inside ODataConnectedService\src\Common\CodeGeneratorUtils.cs. This method is called only at ODataConnectedService\src\CodeGeneration\V3CodeGenDescriptor.cs inside the AddNugetPackages() method:

var wcfDSInstallLocation = CodeGeneratorUtils.GetWCFDSInstallLocation();
var packageSource = Path.Combine(wcfDSInstallLocation, @"bin\NuGet");

Path.Combine throws the aforementioned exception if either of the parameters is null and PR #68 addresses this issue.

xuzhg pushed a commit that referenced this issue Oct 19, 2017
@xuzhg
Copy link
Member

xuzhg commented Oct 19, 2017

Merged related PR at: 196d8b8

@xuzhg
Copy link
Member

xuzhg commented Oct 19, 2017

Please let us know or re-open this if you have further questions.

@xuzhg xuzhg closed this as completed Oct 19, 2017
@LiQuick
Copy link

LiQuick commented Oct 27, 2017

Just installed the OData Connected Service extension via Visual Studio --> Tools --> Extensions and Updates, but still have this issue. Is this already packaged and rolled out?
odata connected services 1
odata connected services 2
odata connected services 3

@AlanWong-MS
Copy link
Contributor

There hasn't been a new package yet. I'll be working on the next release. It should be within a couple of weeks.

@siberianguy
Copy link

siberianguy commented Oct 28, 2017

@AlanWong-MS Is it possible to include the fix to this very critical problem?

@LiQuick
Copy link

LiQuick commented Oct 29, 2017

Is there a novice workaround to this? It seems it needs a registry key that is missing on our installations. Can anybody point out which key and if the value must be a meaningful value (path to an executable) or that the value could also be an empty string? I have no right to ask for any action on your part but waiting a couple of weeks ain't an option for me and the other option is reinstalling my visual studio 2013 setup.

@mohsenno1
Copy link
Contributor

@LiQuick I have mentioned to a workaround in my previous comments.

First install Microsoft WCF Toolkit from the link bellow:

WCF Toolkit

and then go to the registery, find the following key:

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services]

and rename "VS 2010 Tooling" to "VS 2014 Tooling"

It's better to create a duplicate of that key and then rename the duplicate instead of changing the original one.

@LiQuick
Copy link

LiQuick commented Oct 30, 2017

Thank you Mohsenno1 for the help. I got it to work but instead of having "VS 2010 Tooling" I had a "reg folder" with the name "5.6". I exported this folder and changed 5.6 into "VS 2014 Tooling" and it worked (I guess).

@AlanWong-MS
Copy link
Contributor

@siberianguy, we'd love to review and accept any PRs that address that feature gap, but at this time, we don't have resources allocated to the item.

@v-tbert
Copy link

v-tbert commented Nov 7, 2017

I encountered this issue to and @mohsenno1's workaround didn't produce the desired registry key. I had to do the same as @LiQuick. Everyone with a clean install of VS who tries to use an ODATA service is going to get this so I really think it should be prioritized higher but in the meantime, saving the below to a .reg file and importing should work for most people:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services]

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services\VS 2014 Tooling]
"Version"="5.6.61587.0"
"InstallLocation"="C:\Program Files (x86)\Microsoft WCF Data Services\5.6\"

@ghost
Copy link

ghost commented Nov 22, 2017

@mohsenno1 , thank you for the fix, this saved me today! This is indeed a problem that should be fixed asap!

@rogerfar
Copy link

@AlanWong-MS You remove a feature from VS2017 and then ship it's replacement broken, I would assume this is top priority at MS, I see VS updates come out every other week and this is still broken.

@VeryCrazyDog
Copy link

My colleague encountered the same issue on VS 2017. @mohsenno1 and @LiQuick mentioned a workaround but that will result using an old version of WCF Data Services Tool.

It seems that the required WCF Data Services Tool (VS 2014 Tooling) comes together with VS 2015. My PC and my another colleague PC only installed VS Pro 2015 and never installed VS 2017, and we both have the folder C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4 and according to the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft WCF Data Services\5.6.4, it is version 5.6.62175.4. We also have the registry HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft WCF Data Services\VS 2014 Tooling.

So what I do is, I send the files and registry to my colleagues who have the issue and had VS 2015 uninstalled, and the problem is solved.

@AmirImam
Copy link

AmirImam commented Feb 9, 2018

Hi,
Now I have same issue
I am using ASP API 2 with OData v3 and Visual Studio 2017 Community
How can I fix it

@FabianBigler
Copy link

I'm having the same issue with OData V3 and using VS2017, getting the following error:
"The specified OData API cannot be updated because OData APIs are now only supported with Connected Services."

The only workaround that works for me is Opening VS2015 to Add or Update OData Service References.

Please fix this!

@AdReTos
Copy link

AdReTos commented Mar 7, 2018

Good day to everyone.

Buy a new computer, and install Visual Studio 2017 Community, wanting to use the connected services, I found the same problem, in an old computer I have VS2015 and VS2017, and it works well, the temporary solution is to copy the folder WCF Data Services that it is found in Program Files (x86) to the computer that has the problem. And add the right keys to the registry and with that everything works perfectly.

I share the folder with everything you need, for people who do not have such material, as try to find the installer of the version 5.6.4 RTM and I was impossible to get, apparently installed with VS2015.
https://1drv.ms/f/s!Aj5NbD2-p-qXiBbNUimu7gylWHBW

Greetings from Mexico

@LiQuick
Copy link

LiQuick commented Mar 7, 2018

The whole new connected service tool is flawed. Connecting to a password protected odata service is also not possible.

@karpediemnow
Copy link

@LiQuick I have mentioned to a workaround in my previous comments.

First install Microsoft WCF Toolkit from the link bellow:

WCF Toolkit

and then go to the registery, find the following key:

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services]

and rename "VS 2010 Tooling" to "VS 2014 Tooling"

It's better to create a duplicate of that key and then rename the duplicate instead of changing the original one.

After that I was unable to find the key
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services\VS 2014 Tooling]
or
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services\VS 2010 Tooling]
but only
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft WCF Data Services\5.6]

If you are in this situation you need to create it.
I have attached the reg key to fix it
WCF_FIX.reg.txt

I hope can help somebody!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests