0

I'm using Google Analytics Core Reporting API. I can successfully run my request with a code like this.

DataResource.GaResource.GetRequest requestData = googleAnalyticsService.Data.Ga.Get(profiles, startDateStr, endDateStr, metrics);
requestData.Dimensions = dimensions;
requestData.MaxResults = Globals.MAX_RESULTS;

responseData = requestData.Execute();

So in my responseData object I have all the data that I need. But I also need to know when I have an error in my request. So I need to catch a GoogleApiException that has an HttpStatusCode property. This Http status code will let me know if I have reached my quota of requests per day so I can continue receiving information 24 hours after that. But when I catch an exception like this:

catch (GoogleApiException gapiex)
{
   logger.WriteToLog("GETPROFILEDATA", "Google API exception: " + gapiex.HttpStatusCode);
   break;
}

I get an error that says:

The type 'System.Net.HttpStatusCode' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

And I cannot seem to find the library neither via NuGet nor elsewhere. Is there another way of getting the status code or does anyone have the library somewhere?

disasterkid
  • 6,948
  • 25
  • 94
  • 179

1 Answers1

1

Make sure your .NET framework is patched. Microsoft released patches to .NET to allow Portable Class Libraries to properly find the appropriate runtime. KB2468871 patch is available at http://www.microsoft.com/en-us/download/details.aspx?id=3556.

If you are seeing the above exception (or something like it), it means you're missing the latest .NET framework patches.

peleyal
  • 3,472
  • 1
  • 14
  • 25
  • Hi, for info: My project runs in ISS 6.0 on windows server 2003 SP2. My project use Google.Apis and on server I take an error like this. I tried to patch the framework with this link.But it has some prerequisite updates. Please dont forget to install them beforehand. They are KB2600217and KB2533523. I could patch framework with windows update. – whitestream Dec 12 '14 at 09:21