ajmal744 / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

Opening auth URL throws "Class not registered" exception on Windows 8 + Chrome #529

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the Books API Sample: List MyLibrary
https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth

On Windows 8.1 with Chrome as default browser.
Requirement: Running the code with elevated permissions (as Administrator).
(Either inside Visual Studio 2013 or outside) 
Works fine when running WITHOUT elevated permissions.

What is the expected output? What do you see instead?

Expected: The authrozation url is opened in Chrome.

What happens:
This line: Process.Start(authorizationUrl)
inside 
Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.ReceiveCodeAsync
throws the following exception:

System.ComponentModel.Win32Exception occurred
  _HResult=-2147467259
  _message=Class not registered
  HResult=-2147467259
  IsTransient=false
  Message=Class not registered
  Source=System
  ErrorCode=-2147467259
  NativeErrorCode=-2147221164
  StackTrace:
       at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
  InnerException: 

What version of the product are you using?

Google.Apis 1.9.0
Google.Apis.Auth 1.9.1
(Latest 2015-01-22)

What is your operating system?

Windows 8.1 Pro x86

What is your IDE?

VS 2013

What is the .NET framework version?

4.5.1

Please provide any additional information below.

The reason this happens:
http://weblog.west-wind.com/posts/2012/Dec/12/ProcessStart-and-ShellExecute-fail
s-with-URLs-on-Windows-8

One could argue that this is a Chrome bug, but since it's also a Google product 
it should play nice together with your API. Also, the fix is extremely simple 
and if it doesn't have any side effects please consider a patch.

Others having the same problem:
http://stackoverflow.com/q/14585709/2440
http://stackoverflow.com/q/12206368/2440

The fix is replacing Process.Start with this:
var startInfo = new ProcessStartInfo("explorer.exe", authorizationUrl);
Process.Start(startInfo);
Source: http://stackoverflow.com/a/12248929/2440

Original issue reported on code.google.com by si...@rebelbetting.com on 22 Jan 2015 at 12:48