1

I'm trying to reach the Google API Services (Plus Service in this case), using simple C# console application. Each time I call the API functions I'm encountering a very weird exception:

An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module.

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

This is happened when I'm getting the API endpoints like this example:

Client.People.Get("me").Execute();

Did anyone got this problem before?

EDIT:

I have downloaded the GPlus sample, and still getting the same problem, but now inside:

Oauth2Service.TokeninfoRequest request = service.Tokeninfo();

I think the common case here is about generated code classes:

  1. https://code.google.com/p/google-api-dotnet-client/source/browse/20120425-1.1.4497-beta/Generated/Source/Google.Apis.Oauth2.v2.cs?repo=contrib&name=20120503-1.2.4506-beta

  2. https://code.google.com/p/google-api-dotnet-client/source/browse/Current/Generated/Source/Google.Apis.Plus.v1.cs?repo=contrib&r=c757b64c06e143c8b28bda15b4ec7e6a2738d2e5

EDIT 2:

I'm attaching the stacktrace:

at Google.Apis.Plus.v1.PeopleResource.GetRequest.set_UserId(String value) at Google.Apis.Plus.v1.PeopleResource.GetRequest..ctor(IClientService service, String userId) in c:\code.google.com\google-api-dotnet-client\default_gen\Tools\Google.Apis.NuGet.Publisher\Template\Build\Google.Apis.Plus.v1.cs:line 2661 at Google.Apis.Plus.v1.PeopleResource.Get(String userId) in c:\code.google.com\google-api-dotnet-client\default_gen\Tools\Google.Apis.NuGet.Publisher\Template\Build\Google.Apis.Plus.v1.cs:line 2649 at Core.External.GoogleService.GooglePlusApplicationClient.Test() in e:\Copy\Feedly\Backend\Core.External.GooglePlus\GooglePlusApplicationClient.cs:line 34 at FeedlyTest.Program.Main(String[] args) in e:\Projects\Feedly\Backend\Testing\Program.cs:line 88

EDIT 3:

When I'm using the Ctrl+F5 combination, it's working. I read that combination is disabling the debugger. First thought, maybe in the debugger mode, the system is running at 32bit (and then can't access the memory which outside the 32bit boundary) . I tried to change the debug platform to 64bit, but it wasn't help.

weizenberg
  • 302
  • 2
  • 13
  • Which version of the library do you use? The latest versions are 1.8.2 for the core library and 1.8.1.* for G+ API. The files that you attached are old. – peleyal Jul 14 '14 at 15:48
  • I'm using the latest version (1.8.1) from NUGET, just attached the related classes (This what I got by google search)... Also got the same problem with YouTube API too – weizenberg Jul 14 '14 at 15:58
  • Are you on Visual Studio 2012 or later? – class Jul 18 '14 at 15:43
  • I'm using Visual Studio 2013 – weizenberg Jul 18 '14 at 17:03
  • The stacktrace (in Edit 2) - is from a different call, please add the right call. Are you running VS as admin? It looks like something in your environment is missing.... But we still can't figure out what it is. – peleyal Jul 20 '14 at 15:13
  • Sorry, replaced with the right one. Running as administrator and still got the problem – weizenberg Jul 21 '14 at 08:20

2 Answers2

0

Under Project Properties -> Build -> Platform Target: Try changing from "Any CPU" to "x86" or instead try turning on "Prefer 32-bit".

adams
  • 606
  • 7
  • 19
0

What sample are you using? The Google+ Quickstart sample is the newest. Also, you might find this blog post on OAuth 2 flows in .NET useful.

Note that the Google+ sample does currently work in Xamarin as well as Visual Studio, so you could try to determine whether it's your environment using the freely available IDE.

Make sure when using the quickstart that you're going to http://server:port/signin.ashx - in some configurations, the web app will default to another route.

Can you also post more information on the code you're using? For example, the following code shows a more complete example of your tokeninfo call from above:

Oauth2Service service = new Oauth2Service(
    new Google.Apis.Services.BaseClientService.Initializer());
Oauth2Service.TokeninfoRequest request = service.Tokeninfo();
request.AccessToken = token.AccessToken;

Tokeninfo info = request.Execute();

I created a very simple Google .NET Client API demo on GitHub that you can clone:

git clone https://github.com/gguuss/google-dotnet-demo

When you open the project in Visual Studio, restore the NuGet packages, build the project, and then input an access token. If everything works, the demo will show you some of the TokenInfo data.

I have added another demo showing authorization. When I did this, I tested with Visual Studio 2013 and I had to add the following as a post-install step...

copy /Y "$(SolutionDir)packages\Microsoft.Bcl.Async.1.0.16\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll" "$(TargetDir)Microsoft.Threading.Tasks.Extensions.Desktop.dll"

...as described in this Stack Overflow question.

Community
  • 1
  • 1
class
  • 8,621
  • 29
  • 30
  • I used the sample from here: https://github.com/googleplus/gplus-quickstart-csharp/ Also the problem is persists on Youtube API too... I'm sure the problem source isn't in my code, maybe in my environment. – weizenberg Jul 15 '14 at 08:08
  • Added more resolution options. – class Jul 18 '14 at 15:49
  • Thanks, but I used the both codes, from the sample and from the blog post. Same error on both. I'm using VS2013, what else can I try? – weizenberg Jul 18 '14 at 20:31
  • I created a simple console project that works for me and added it to the answer. – class Jul 22 '14 at 05:46
  • You'll not believe me, but the problem still exists... I'm sure it depending somehow on my machine... – weizenberg Jul 22 '14 at 09:56
  • Not sure how else I can help @Yoni92. Please add as much information to your question as possible regarding your configuration - e.g. OS version / VS version so that the team can better determine whether this is a bug. From your stack trace it looks like you are not using the NuGet packages but instead are referencing generated client libraries in your project. You should not be doing this. – class Jul 23 '14 at 00:10
  • 1
    I'm using only NuGet packages (in you example I made NuGet Restore). My OS version is Windows 7 (build 7601: Service Pack 1), and my VS version is 12.0.21005.1 If you want, you can reach me privately at Hangouts and review this problem with remote desktop service. – weizenberg Jul 23 '14 at 07:24
  • Almost a year passed but this bug in Google API library is still there :( – Alex May 18 '15 at 17:38