kelvinRosa / 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

Problems using Google.Apis.Authentication.OAuth2.dll #350

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was trying to run the sample program in given in 
https://developers.google.com/drive/quickstart-cs#step_3_set_up_the_sample, but 
there are many problems. I am using Win Xp SP3, VS 2010 Professional, .NET 
Framework 4.0. The problems come on these functions 
2. OAuth2Authenticator
3. ApplyAuthenticationToRequest

Kindly help me.

Problem:

An unhandled exception of type 'System.TypeLoadException' occurred in 
mscorlib.dll

Additional information: Method 'Method' in type 
'Google.Apis.Authentication.OAuth2.OAuth2Authenticator`1' from assembly 
'Google.Apis.Authentication.OAuth2, Version=1.4.0.28223, Culture=neutral, 
PublicKeyToken=null' does not have an implementation.

I am using latest dlls from 
https://developers.google.com/resources/api-libraries/download/drive/v2/csharp

Any help would be appreciated. Thanks in advance.

Original issue reported on code.google.com by ranjan2...@gmail.com on 9 Jul 2013 at 10:53

GoogleCodeExporter commented 9 years ago
Did you follow our build wiki page 
(https://code.google.com/p/google-api-dotnet-client/wiki/Build)?
Do you use NuGet?

Can you please add the exact stack trace?

Original comment by pele...@google.com on 9 Jul 2013 at 6:32

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your response. Yes after posting my problem I used all the Nuget 
packages posted in the page 
https://code.google.com/p/google-api-dotnet-client/wiki/Build and followed the 
steps given there, still same problem.

The app.config file was built by the IDE and in the csproj file
<Import 
Project="..\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets
" /> is already present.

I am attaching Detailed and Diagnostic Build Output in separate text files. 
Also the video is very outdated as it doesn't show them using Nuget packages.

Thanks & regards

Original comment by ranjan2...@gmail.com on 10 Jul 2013 at 6:40

Attachments:

GoogleCodeExporter commented 9 years ago
Theres nothing in the call stack. Its a runtime error. Exception is included in 
the text file.

Original comment by ranjan2...@gmail.com on 11 Jul 2013 at 5:59

Attachments:

GoogleCodeExporter commented 9 years ago
I have users reports about this issue too: 
https://code.google.com/p/google-api-dotnet-client/issues/detail?id=353&thanks=3
53&ts=1373534346

There was no such issue at the 
google-api-services-drive-v2-rev43-java-1.13.2-beta that I used before.

Original comment by ext.andr...@gmail.com on 11 Jul 2013 at 9:23

GoogleCodeExporter commented 9 years ago
Thats right - I got the same issue and everything in the website 
https://code.google.com/p/google-api-dotnet-client/issues/detail?id=353&thanks=3
53&ts=1373534346 is what I am getting. Google should start living upto its 
expectations. Didn't expect such silly mistakes.

Original comment by ranjan2...@gmail.com on 11 Jul 2013 at 12:02

GoogleCodeExporter commented 9 years ago
From the Diagnostic file you sent, it looks like you are using all the 
assemblies from the bundle, and not using NuGet.
Can you please start over again? Create a project, and follow 
https://code.google.com/p/google-api-dotnet-client/wiki/Build - Steps for 
building + using NuGet (Don't any step which mentioned under NOT using NuGet)?
I just did it with the drive bundle and it works using VS2012 (It should work 
on VS2010) as well using Windows 7.

Regarding your comment on Google, be aware that we are trying our best to 
provide the best support both on StackOverflow and on this issue tracker.
Please continue to update - I'm pretty sure that after you will start over 
again using the NuGet steps, it will work.

Eyal

Original comment by pele...@google.com on 14 Jul 2013 at 1:52

GoogleCodeExporter commented 9 years ago
Hi Eyal,

I did the same as you told. The google-drive-v2-rev82-csharp-1.4.0-beta folder 
is on my desktop. I added references to the following assemblies : 

DotNetOpenAuth.dll (in google-drive-v2-rev82-csharp-1.4.0-beta\Lib folder)
Google.Apis.dll (in google-drive-v2-rev82-csharp-1.4.0-beta\Lib folder)
Google.Apis.FullProfile.dll (in google-drive-v2-rev82-csharp-1.4.0-beta\Lib 
folder)
Google.Apis.Authentication.OAuth2.dll (in 
google-drive-v2-rev82-csharp-1.4.0-beta\Lib folder)
Google.Apis.Drive.v2.dll (in 
google-drive-v2-rev82-csharp-1.4.0-beta\google-drive-v2-rev82-csharp-1.4.0-beta-
bin folder)

I also installed the following Nuget packages :

Microsoft.Net.Http
Microsoft.Bcl.Async
Newtonsoft.Json
Zlib.Portable
log4net

There are no errors in the build. There is just an exception as posted in the 
previous comment. The Detailed and Diagnostic file are showing results after 
installing the Nuget packages. Since comment #2 I have added the Nuget packages.

I am also attaching two snapshots. For now I am using the Google Docs Api 
(depreciated). Kindly help me in solving this problem. Revert for any thing 
that I am missing or I am doing wrong. Thanks

Original comment by ranjan2...@gmail.com on 15 Jul 2013 at 6:14

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 15 Jul 2013 at 1:31

GoogleCodeExporter commented 9 years ago
Hi,
I spent several hours trying to understand the problem this issue and 
https://code.google.com/p/google-api-dotnet-client/issues/detail?id=353.

1. Can you please send me your project\projects file\s?
You can also send the new diagnostic files.

2. Can you please run the Drive sample API 
(http://samples.google-api-dotnet-client.googlecode.com/hg/Drive.Sample/README.h
tml) and let me know if it works for you?

3. Just to let you know, 
I created a drive library (which uses the Drive API) using the instructions in 
our build page. Then I created a console application which uses this new drive 
library. It works for me. I'm using VS2012, NuGet 2.5.40416.9020 on Windows 7 
machine.

As you are not the only user who complains about it, I put my focus on that 
issue, so any feedback and information you can send me will be appreciated.

Thanks

Original comment by pele...@google.com on 15 Jul 2013 at 8:24

GoogleCodeExporter commented 9 years ago
Hi Eyal,

Attached here is my project. Its very simple - the first project that I had to 
learn from https://developers.google.com/drive/quickstart-cs

CLIENT_ID is my Client Id
CLIENT_SECRET is my Client Secret

Both the values I have not disclosed in the attached project as anybody can 
have access to it.

I am also attaching the output from the Build in the levels, i.e, diagnostic, 
detailed and normal.

I also ran the Drive Sample, and got the same results. I am attaching 4 
snapshots to show the steps I followed to run the Drive sample (that you 
suggested) and the results I got.

I also ran the program in https://developers.google.com/drive/quickstart-cs in 
my home.
Configuration of my home laptop : Win 8 64 bit, VS Express for Desktop Update 
2, .Net 4.5 and it gave no problem.

If you need any more information, kindly ask. I will give more information on 
the steps I followed and the results I got.

Thanks.

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 5:53

Attachments:

GoogleCodeExporter commented 9 years ago
Uploading my project takes a lot of time and gives me Error 400! Can you 
suggest some methods so that I can send you my ConsoleApplication1.zip (12.2 
MB)?

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 5:58

GoogleCodeExporter commented 9 years ago
Can you upload your project to your drive API and share that file with me (I'm 
cc on this issue)?
Meantime I'll talk a look in the files you already sent me.

As I understand you use VS2010 and .NET 4.5 frameowrk, please approve.

Original comment by pele...@google.com on 16 Jul 2013 at 12:58

GoogleCodeExporter commented 9 years ago
Hey,

I forgot to mention the version - Its VS 2012, .Net Framework 4.5, there's no 
option to edit the comment. And I don't know how to upload the project to drive 
API? Can you explain how to do that?

Thanks.

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 3:49

GoogleCodeExporter commented 9 years ago
Oh sorry I meant you should upload the project to your google drive 
(https://drive.google.com) and then you can share the file there with me.

I'll try to follow your exact step using .NET 4.5
Thanks

Original comment by pele...@google.com on 16 Jul 2013 at 3:56

GoogleCodeExporter commented 9 years ago
Hey,

I am following the steps mentioned in 
https://code.google.com/p/google-api-dotnet-client/wiki/Build in my home right 
now(Win 8), and the same steps I am following in my office (Win XP SP 3). Still 
the differences. I will upload the ConsoleApplication1.zip (12.2 MB), which is 
not running properly after 11 hours when I will be in office. Now I am in home 
and I have copy-pasted the same code given in 
https://developers.google.com/drive/quickstart-cs in my another C# application 
(in my home laptop, which is running). The same code is in office also, but its 
not running.  Do you want the code which is running(of my home laptop)?

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 4:55

GoogleCodeExporter commented 9 years ago
Let's start by sending me the app.config and your proj file for each of your 
projects. How many projects did you create? Only the main console application 
or you have other class libraries as well?

Original comment by pele...@google.com on 16 Jul 2013 at 5:17

GoogleCodeExporter commented 9 years ago
So it's really confusing.
I created a .NET 4.5 application using the Google Drive API.
I followed the instructions on our Build page, using the code 
https://developers.google.com/drive/quickstart-cs and it worked.

I run that code on Windows 7 with VS2012 professional.
Because this issue and issue 353 are similar, I'm going to create a new VM with 
VS Express for Desktop Update 2 on another clean Windows 7 machine, and 
hopefully the problem will occur in that machine as well.

Keep me updated,
Eyal

Original comment by pele...@google.com on 16 Jul 2013 at 6:51

GoogleCodeExporter commented 9 years ago
Hey Eyal,

Configuration in office:
Win XP SP3
VS 2010 Professional
.Net Framework 4.0

Result:
Not Working

The output from Build are in comment #10 in three different levels, i.e., 
diagnostic, detailed and normal.

Configuration in home (laptop):
Win 8
VS 2012 Express for Desktop
.Net Framework 4.5

Result:
Working

I have not uploaded any .txt or .png file from my home. All the attachments are 
from my office where the program is not working properly. I didn't upload 
anything from my home and/or didn't talk much about the project that I compiled 
yesterday and today  (which is working) as there is no problem in my home 
application. I have copy-pasted the same code from 
https://developers.google.com/drive/quickstart-cs and followed the same steps 
in both the application (in my home as well as office).

I will go to office today 9:30 AM. Its 12:45 AM now. I am in India. We are not 
allowed to carry laptops or pen drives in my office. Its totally isolated, 
otherwise I would be uploading my ConsoleApplication1.zip (12.2 MB) from my 
home.

I am doing homework on the same project in the same salary. I have accomplished 
the task that my boss gave me using Google Docs API (deprecated).

Do you need some more clarification?

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 7:15

GoogleCodeExporter commented 9 years ago
The ConsoleApplication1.zip (12.2 MB) that I am talking about is my office 
application which is not working and the results are posted in different 
comments in this thread. I didn't upload any attachment from the project that 
is working properly ,i.e, from my home.

Original comment by ranjan2...@gmail.com on 16 Jul 2013 at 7:17

GoogleCodeExporter commented 9 years ago
So as I understand it works on VS 2012.
I'm going to install VS2010 Express and test the quickstart code there.

Original comment by pele...@google.com on 16 Jul 2013 at 7:30

GoogleCodeExporter commented 9 years ago
I managed to run the quickstart using VS2010 (without NuGet) on a Windows 7 
64bit machine.
Please send me your ConsoleApplication1.zip application, until then I have 
nothing to do.

By the way, I also got the same System.Net warnings as you just remove the 
System.Net dependency. It works both with and without that dll.

Try to remove it, and let me know.
Eyal

Original comment by pele...@google.com on 16 Jul 2013 at 7:58

GoogleCodeExporter commented 9 years ago
Using Nuget packages and removed System.Net. But I think exception isn't 
because of the System.Net.dll. The snapshot says it. And I know it works 
without that also. It works without Google.Apis.FullProfile.dll also (I added 
it because it is mentioned in the 
https://code.google.com/p/google-api-dotnet-client/wiki/Build page).

Original comment by ranjan2...@gmail.com on 17 Jul 2013 at 4:42

Attachments:

GoogleCodeExporter commented 9 years ago
The above snapshots are from my office application which is not running. I have 
used Nuget packages and removed System.Net.dll.

https://docs.google.com/file/d/0Bw0WH1sYW6aZdXh4RDJ5R0FRWlU/edit?usp=sharing is 
the link to ConsoleApplication1.zip (12.2 MB)

Original comment by ranjan2...@gmail.com on 17 Jul 2013 at 4:51

GoogleCodeExporter commented 9 years ago
OK. Your code run in my machine (Windows 7 64bit) - of course it doesn't work 
because the client_id and client_secret are invalid.
So I recompile your code with my client secrets and it worked (on a clean 
Windows 7 64bit using VS 2010 EXpress).

Which .NET framework is installed in your machine? I'm using .NET v4.0.30319 as 
you see, using regedit, and then Computer -> HKEY_LOCAL_MACHINE -> SOFTWARE -> 
Microsoft -> .NETFramework.

Original comment by pele...@google.com on 17 Jul 2013 at 1:22

Attachments:

GoogleCodeExporter commented 9 years ago
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319
I don't know about the reason. Do you know? Because its not just me 
experiencing this issue.

Original comment by ranjan2...@gmail.com on 17 Jul 2013 at 1:29

GoogleCodeExporter commented 9 years ago

Original comment by ranjan2...@gmail.com on 17 Jul 2013 at 1:31

Attachments:

GoogleCodeExporter commented 9 years ago
I'm trying my best :) 
I'm investigating this issue in the last couple of days...

Try something new: can you change your sln as following (x86.ActiveCfg = 
Debug|x86 ==> Any CPU.ActiveCfg = Debug|Any CPU)

e.g. 
from:
{77F6ADF5-E41C-482D-9126-0B04DC91C01E}.Debug|x86.ActiveCfg = Debug|x86
to:
{77F6ADF5-E41C-482D-9126-0B04DC91C01E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

Let me know ASAP,
Thanks,
Eyal

Original comment by pele...@google.com on 17 Jul 2013 at 1:39

GoogleCodeExporter commented 9 years ago
I mean you should change the following:
from:
Debug|x86.ActiveCfg = Debug|x86
Debug|x86.Build.0 = Debug|x86
Release|x86.ActiveCfg = Release|x86
Release|x86.Build.0 = Release|x86
to:
Debug|Any CPU.ActiveCfg = Debug|Any CPU
Debug|Any CPU.Build.0 = Debug|Any CPU
Release|Any CPU.ActiveCfg = Release|Any CPU
Release|Any CPU.Build.0 = Release|Any CPU

and rebuild

Original comment by pele...@google.com on 17 Jul 2013 at 1:58

GoogleCodeExporter commented 9 years ago
I suspect also the following:
You GAC contains an older version of Google.Apis.Authentication.OAuth2.dll 
which is loaded and you actually don't use the right version from the bundle.

Read 
http://stackoverflow.com/questions/49972/in-what-order-are-locations-searched-to
-load-referenced-dlls for more information.

So, my suggest is:
1. Use http://msdn.microsoft.com/en-us/library/9x295t9k(v=vs.100).aspx to 
present the assemblies in your GAC.
I ran Developer Command Prompt from Start -> All Programs -> Microsoft Visual 
Studio -> Visual Studio Tools -> Developer Command Prompt
then I ran "gacutil /l"
[If you can please pipe the content to a file and send it to me, so: gacutil /l 
> c:\Users\Administrator\Documentes\assemblies.txt]

2. In my opinion Google.Apis.Authentication.OAuth2 will appear there and we 
should remove it.
Use http://msdn.microsoft.com/en-us/library/aa559881(v=bts.20).aspx to delete 
it.

Other options are that several other assemblies that we use like Google.Apis, 
DotNetOpenAuth or others appear in your GAC. So we may try to delete them from 
the GAC as well.

Original comment by pele...@google.com on 17 Jul 2013 at 4:19

GoogleCodeExporter commented 9 years ago
You will be happy to read our new blog post: 
http://google-api-dotnet-client.blogspot.com/
from today we provide Google.Apis and Google.Apis.Authentication NuGet packages.
I'm still waiting for your answers regarding the several question I had.

Original comment by pele...@google.com on 19 Jul 2013 at 3:44

GoogleCodeExporter commented 9 years ago
Hey,

Actually I am back on the previous project that I was assigned and it has a 
deadline. This project which we were discussing about is completed (I have used 
Google Docs API deprecated). Still I would try your suggestions. I didn't post 
anything about it for not demotivating you. As soon as I complete the previous 
project (which is pending since months), I will follow up with this project.

Thanks

Original comment by ranjan2...@gmail.com on 19 Jul 2013 at 6:23

GoogleCodeExporter commented 9 years ago
Google APIs Client Library was there since months. How come I didn't I know 
about it?

Original comment by ranjan2...@gmail.com on 19 Jul 2013 at 6:25

GoogleCodeExporter commented 9 years ago
I just discovered that as well.
It wasn't maintained by Google.
From today we will support it officially.
Let me know, if we won't solve it in the next days, I'll appreciate if we could 
do hangout or some application that you will shared your screen, because I 
can't reproduce that problem.
For that it will be great if you would be able to send me your personal e-mail.

Thanks so much for your collaboration, and I'm really sorry that I still didn't 
resolved that issue.

Eyal

Original comment by pele...@google.com on 19 Jul 2013 at 6:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm pretty sure that somehow your laptop and your office desktop are loading a 
different version of System.Net.dll (one uses the right version - .NET 4.0, 
while the other uses the old version, which doesn't include the right signature 
of WebHttpRequest for example).
I'll continue to investigate, but it's a bit difficult, because I can't 
reproduce it.

Original comment by pele...@google.com on 19 Jul 2013 at 7:39

GoogleCodeExporter commented 9 years ago
Can you try the following (from 
http://stackoverflow.com/questions/18060340/asp-net-using-analytics-reporting-ap
i-does-not-work-on-server) and let me know:

"Copying System.Net.Http from the bin and replacing the one in 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319 worked!" by user1697748

Original comment by pele...@google.com on 13 Aug 2013 at 11:58

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 13 Aug 2013 at 11:58

GoogleCodeExporter commented 9 years ago
1) I didn't try #36
I deleted the whole project and made it again. I followed steps under NUget 
Users under 
https://code.google.com/p/google-api-dotnet-client/wiki/APIs#Drive_API nut 
still two dlls were missing: DotNetOpenAuth.dll and 
Google.Apis.Authentication.OAuth2.dll. I have referenced the two dlls from 
google-drive-v2-rev92-csharp-1.4.0-beta. Now, the program in running.

2) 
https://developers.google.com/resources/api-libraries/download/drive/v2/csharp 
doesn't have the required dlls.

Original comment by ranjan2...@gmail.com on 21 Aug 2013 at 8:34

GoogleCodeExporter commented 9 years ago
So as I understand it works now, right?

You should also install Google.Apis.Authentication package (this package 
contains DotNetOpenAuth.dll and Google.Apis.Authentication.OAuth2.dll

We will make it clearer....
Thanks for the feedback!

Original comment by pele...@google.com on 21 Aug 2013 at 10:56

GoogleCodeExporter commented 9 years ago
Ya, Its working now.

Can you enlighten some more points on installing Google.Apis.Authentication 
package (package containing DotNetOpenAuth.dll) and 
Google.Apis.Authentication.OAuth2.dll?

Original comment by ranjan2...@gmail.com on 21 Aug 2013 at 8:33

GoogleCodeExporter commented 9 years ago
Of-course!

First of all you can take a look in our build page - 
https://code.google.com/p/google-api-dotnet-client/wiki/Build#Using_NuGet.

Our generated packages (e.g. Drive 
https://www.nuget.org/packages/Google.Apis.Drive.v2) Are PCL. It means that 
they target Windows Phone, Windows RT, etc.

Currently our Authentication package is for .NET 4 and .NET 4.5 regular 
applications. In the future it will be PCL and we will add dependency in the 
Authentication package. But for now, you will need to add it manually.

So...
You need to add the right NuGet package you are working with (e.g. Drive) and 
then add also dependency in 
https://www.nuget.org/packages/Google.Apis.Authentication/

Is it clearer?

Original comment by pele...@google.com on 21 Aug 2013 at 9:42

GoogleCodeExporter commented 9 years ago
Yes, I got it.
I installed two NuGet packages:
1) Google.Apis.Drive.v2 and
2) Google APIs OAuth2
Now, its working.

And also I wan't to bring out one small issue - the packages installs doesn't 
install updated version of Microsoft HTTP Client Libraries.

I have checked this on my Office Computer as this computer was having the 
problem.

Original comment by ranjan2...@gmail.com on 22 Aug 2013 at 5:12

GoogleCodeExporter commented 9 years ago
I meant there was some problem in executing the program in my Office Computer.

And this issue is not being shown in 
https://code.google.com/p/google-api-dotnet-client/issues/list?

Original comment by ranjan2...@gmail.com on 22 Aug 2013 at 5:15

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 22 Aug 2013 at 12:52

GoogleCodeExporter commented 9 years ago
Your office computer has which problem? The binding issue of OAuth2 library or 
the new HttpClient package? Please try to be more specific...
Thanks.

Regarding HttpClient, I'll open a new issue in this issue tracker to upgrade 
the library in our next release.
Thanks!

Original comment by pele...@google.com on 22 Aug 2013 at 1:08

GoogleCodeExporter commented 9 years ago
Now, no problem in executing program on Office Computer. I followed steps in 
#42.

Thanks

Original comment by ranjan2...@gmail.com on 23 Aug 2013 at 12:33

GoogleCodeExporter commented 9 years ago
I'm happy to hear! I'm closing this issue :-)

Original comment by pele...@google.com on 23 Aug 2013 at 12:47

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 23 Aug 2013 at 1:21

GoogleCodeExporter commented 9 years ago
Hi Team,

I got below Error If any Solution please give me 

"Method 'ApplyAuthenticationToRequest' in type 
'Google.Apis.Authentication.OAuth2.OAuth2Authenticator`1' from assembly 
'Google.Apis.Authentication.OAuth2, Version=1.5.0.28223, Culture=neutral, 
PublicKeyToken=null' does not have an implementation."

please check &  revert me 

Original comment by prashant...@gmail.com on 10 Oct 2013 at 10:08

GoogleCodeExporter commented 9 years ago
Make sure your .NET framework is patched. Microsoft released patches to .NET to 
allow Portable Class Libraries to properly find the appropriate runtime 
(KB2468871 - 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.

Please let me know!

Original comment by pele...@google.com on 10 Oct 2013 at 1:39