MyOwnClone / google-api-dotnet-client

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

System.Security.VerificationException: Operation could destabilize the runtime. #356

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

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

What version of the product are you using? On what operating system? On
what IDE?

Please provide any additional information below.

Original issue reported on code.google.com by srav...@risecorp.com on 16 Jul 2013 at 5:41

Attachments:

GoogleCodeExporter commented 9 years ago
Please provide more information

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

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
  private static Userinfo GetUserInfo(IAuthenticator credentials)
        {
            Oauth2Service userInfoService = new Oauth2Service(credentials);
            Userinfo userInfo = null;
            try
            {
                userInfo = userInfoService.Userinfo.Get().Fetch();
            }
            catch (GoogleApiRequestException e)
            {
                Console.WriteLine("An error occurred: " + e.Message);
            }

            if (userInfo != null && !String.IsNullOrEmpty(userInfo.Id))
            {
                return userInfo;
            }
            else
            {
                return null;
            }
        }
while running the code from web server i got an issue : 
"System.Security.VerificationException: Operation could destabilize the 
runtime."
and i have tried in local iis its working fine with out any issue 
note : both .net frameworks are same i.e. .net framework 4.0

Original comment by srav...@risecorp.com on 17 Jul 2013 at 8:46

GoogleCodeExporter commented 9 years ago
First of all you're using an old version of the library. You can download the 
latest version of your API here: 
https://code.google.com/p/google-api-dotnet-client/wiki/APIs.
You should also follow our build page 
(https://code.google.com/p/google-api-dotnet-client/wiki/Build).

Check also - http://msdn.microsoft.com/en-us/library/432cdx67(v=vs.80).aspx.
It looks like there is a conflict in a class library you are using. So my 
recommendation is to start again using the links I'm sending you.

Please let me know

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

GoogleCodeExporter commented 9 years ago
hi, 
Thanks for giving but i got another issue from new dlls

"Method 'ApplyAuthenticationToRequest' 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."

Original comment by srav...@risecorp.com on 18 Jul 2013 at 2:57

Attachments:

GoogleCodeExporter commented 9 years ago
Can we check another option:
I think that your 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 19 Jul 2013 at 3:21

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
hi,
i haven't see any dll that related to "Google.Api.Authentication.OAuth2.dll".
please find the attachments bellow.

Thanks.

Original comment by srav...@risecorp.com on 19 Jul 2013 at 11:23

Attachments:

GoogleCodeExporter commented 9 years ago
Which OS do you use?
Can you please send me a text doc with all your GAC content?

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

GoogleCodeExporter commented 9 years ago
hi,
i am using Windows 7 x64 bit operating system (VS2010), and i am attaching list 
of GAC dll's 

Original comment by srav...@risecorp.com on 19 Jul 2013 at 4:14

Attachments:

GoogleCodeExporter commented 9 years ago
1. Thank you so much for your help so far. I want to continue investigating 
this, but I can't reproduce it on my machine. Is anyway that you will share 
your screen with me with Hangout or some other sharing application?
2. When you compile, do you get the follow warning as well?
warning CS1684: Reference to type 'System.Net.HttpWebRequest' claims it is 
defined in 'c:\Program Files (x86)\Reference 
Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Net.dll', but it could 
not be found
If so - do you have this assembly in the specific folder?
I've it and the version is 4.0.30319.430 as expected.

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

GoogleCodeExporter commented 9 years ago
Can you also send you fusion log output?

Original comment by pele...@google.com on 19 Jul 2013 at 8:53

GoogleCodeExporter commented 9 years ago
hi,
Thanks for giving the information, here i am dropping the fusion log output and 
also i got warning CS1684:warning CS1684: Reference to type 
'System.Net.HttpWebRequest' claims it is defined in 'c:\Program Files 
(x86)\Reference 
Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Net.dll', but it could 
not be found.
but i gone through the following path and i can able to see the dll in that 
location as per the dll concern the version is 4.0.30319.1.
can you please advice me what i have to do now
note : i haven't get any error while executing from local machine.    

Original comment by srav...@risecorp.com on 22 Jul 2013 at 9:15

Attachments:

GoogleCodeExporter commented 9 years ago
Here the System.net.dll file screen shot

Original comment by srav...@risecorp.com on 22 Jul 2013 at 9:19

Attachments:

GoogleCodeExporter commented 9 years ago
So when did you get the errors? Do your users complain about that error? Do 
they have the same path in their machine? (c:\Program Files (x86)\Reference 
Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Net.dll), If not - 
where is this System.Net.dll located on their machine?

Original comment by pele...@google.com on 22 Jul 2013 at 12:46

GoogleCodeExporter commented 9 years ago
After completion of my project, i am going to publish my site  into WebServer. 
While accessing from WebServer i got the issue.   

Original comment by srav...@risecorp.com on 22 Jul 2013 at 12:49

GoogleCodeExporter commented 9 years ago
The WebServer contains .NET 4.0 installed? Does it contain the System.Net.dll 
in GAC?
If you want me to dig in into this and we will try to solve it together by 
sharing your screen (if it's possible), I would be happy to so. The main 
problem I'm having so far, is that I can't reproduce this problem on my 
different VMs, so it's very hard to help you.
We can use Hangout if it works for you. Let me know :)

Original comment by pele...@google.com on 22 Jul 2013 at 12:59

GoogleCodeExporter commented 9 years ago
i have hosted the site in rackspace and if you need i will provide the link.

Original comment by srav...@risecorp.com on 22 Jul 2013 at 1:09

GoogleCodeExporter commented 9 years ago
Please do.
Do you know if .NET 4.0 is installed there?

Original comment by pele...@google.com on 22 Jul 2013 at 2:30

GoogleCodeExporter commented 9 years ago
yes, it is a site having .net framework 4.0 version.
here the link "driveapp.risecorp.com" 

Original comment by srav...@risecorp.com on 22 Jul 2013 at 2:34

GoogleCodeExporter commented 9 years ago
I get error as well, but I can't debug it or do anything. Can you debug the 
code there? See what is exactly installed? Have access to the GAC?

Original comment by pele...@google.com on 22 Jul 2013 at 2:58

GoogleCodeExporter commented 9 years ago
hi,
we can't debug the application in rackspace server. Because it is cloud 
site(shared hosting).  

Original comment by srav...@risecorp.com on 22 Jul 2013 at 3:04

GoogleCodeExporter commented 9 years ago
Hi...

Logs? Something?
Can you ask them if they can send you the content of the GAC? Or if it is some 
problem they saw before?

We won't be able to solve that issue without access to your code there. We need 
to be able to debug that code. What do you think?

I'm trying my best, but I need to get some input, so we can solve that issue. 

Original comment by pele...@google.com on 22 Jul 2013 at 3:21

GoogleCodeExporter commented 9 years ago
this is code i have written in file :
 static IAuthorizationState ExchangeCode(String authorizationCode)
        {
            DPLLogging.WriteError("ExchangeCode" + authorizationCode + "::");
            var provider = new NativeApplicationClient(
                GoogleAuthenticationServer.Description,
                ClientCredentials.CLIENT_ID,
                ClientCredentials.CLIENT_SECRET);
            IAuthorizationState state = new AuthorizationState();
            state.Callback = new Uri(ClientCredentials.REDIRECT_URI);
            try
            {
                DPLLogging.WriteError(state.Callback.ToString());
                state = provider.ProcessUserAuthorization(authorizationCode, state);
                return state;
            }
            catch (ProtocolException)
            {
                throw new CodeExchangeException(null);
            }
        }
AT this line :  provider.ProcessUserAuthorization(authorizationCode, state);
i got a error please check the  last line of log file in attachment
note: last line of log file written by following line of code 
DPLLogging.WriteError(state.Callback.ToString()); 

Original comment by srav...@risecorp.com on 22 Jul 2013 at 3:30

Attachments:

GoogleCodeExporter commented 9 years ago
I understand that somehow the dependency in System.Net.dll doesn't work. But 
the log doesn't really help to me and to you, right?

I need more than that, can you try to figure out with rackspace how you can 
debug? see the GAC? and other important actions to you...?

Original comment by pele...@google.com on 22 Jul 2013 at 3:45

GoogleCodeExporter commented 9 years ago
I get the same exception in my local (desktop) application (here: 
http://www.codeproject.com/Articles/647743/GDrive-Explorer-For-Google-Drive). 
However the issue is only reproducible on some systems. On other systems they 
work perfect.

Dont exactly know why the difference in observations. 

Can you please tell what are the further steps to debug this?

Original comment by hush.tec...@gmail.com on 11 Sep 2013 at 5:53

Attachments:

GoogleCodeExporter commented 9 years ago
1. Do you install Windows 7 service pack1?
2. Do you have the latest NuGet version installed (and you installed the 
required Google.Apis packages from NuGet)?
3. Can you try run one of your samples 
(https://code.google.com/p/google-api-dotnet-client/source/browse/?repo=samples)
 just to make sure that other samples work?

Thanks

Original comment by pele...@google.com on 11 Sep 2013 at 4:17

GoogleCodeExporter commented 9 years ago
Hi, Thanks for your response.

These issues occur on client systems. The above is part of an opensource 
article on codeproject. Though many users are able to use them, some face these 
kind of problems.

I downloaded nuget packages and bundled the downloaded ones, so all users are 
having the same set of dlls.

Yes, Windows 7 sp1 is available for them. I have confirmed.

I will ask to run the samples. But even without that do you suspect any other 
mistakes, I might be doing?

Original comment by hush.tec...@gmail.com on 11 Sep 2013 at 4:34

GoogleCodeExporter commented 9 years ago
What is the exact error you're having there are two different kind of errors in 
this thread, and I'm confused right now.

Please send me as much details as you have - 
1. What is the exact error
2. Does it happen to all users or only to a group of them
3. If it happens only to a group of them, can you think of something that those 
users installed \ didn't install on their machine.

We will start with that...
Sorry for the delay in my response.

Original comment by pele...@google.com on 12 Sep 2013 at 2:10

GoogleCodeExporter commented 9 years ago
Above Solution not working 

"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 8:47

GoogleCodeExporter commented 9 years ago
Hi team

I got error in Authenticate method  &  please check &  revert me 

My code :

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

// For revocation and REST queries using HTTPRequest.
using System.Net;
using System.Web;
using System.Web.Compilation;

// For string manipulations used in the template and string building.
using System.Text;
using System.Text.RegularExpressions;

// For mapping routes
using System.Web.Routing;
using System.Web.SessionState;

// Generated libraries for Google APIs
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Services;
using Google.Apis.Util;

using Google.Apis.PlusDomains.v1;
using Google.Apis.PlusDomains.v1.Data;

// For OAuth2
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2;

// For JSON parsing.
using Newtonsoft.Json;
using System.Threading;

using System.Diagnostics;
using System.Runtime.InteropServices;

public partial class _Default : System.Web.UI.Page
{
    protected PlusDomainsService ps1;
    protected Google.Apis.PlusDomains.v1.Data.Person me;
    private IAuthorizationState _authstate;

    [DllImport("user32.dll")]
    static extern int GetForegroundWindow();
    [DllImport("user32.dll")]
    static extern int GetWindowText(int hWnd, StringBuilder text, int count); 

    private static class ClientCredentials
    {
        static public string ClientID = "377857239757-8cqiuna6b4ic57rgmoo76i5jjm2eferl.apps.googleusercontent.com";
        static public string ClientSecret = "7VUr2v9YcSnPNXsiFSyzwJvu";
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        authenticate();
    }

    private OAuth2Authenticator<NativeApplicationClient> CreateAuthenticator()
    {
        // Register the authenticator.
        var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
        provider.ClientIdentifier = ClientCredentials.ClientID;
        provider.ClientSecret = ClientCredentials.ClientSecret;

        var authenticator =
            new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization) { NoCaching = true };
        return authenticator;
    }
    private IAuthorizationState GetAuthorization(NativeApplicationClient client)
    {
        String[] reqAuthScopes = new[] { "https://www.googleapis.com/auth/plus.me" };

        // Generate the authstate
        if (_authstate == null)
        {
            // need an authorization state
            _authstate = new AuthorizationState(reqAuthScopes);

            // Create the Url                
            Uri requestURL = client.RequestUserAuthorization(reqAuthScopes);

           Uri url = client.RequestUserAuthorization(reqAuthScopes);

           //  string url = "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=377857239757-8cqiuna6b4ic57rgmoo76i5jjm2eferl.apps.googleusercontent.com&redirect_uri=http://localhost:26611/WebSite4/Default.aspx&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.me";
            // Show the dialog.
            Process.Start(url.ToString());

//            MessageBox.Show("Please click OK after you have copied the token 
from the web site.");

            String authCode = pollActiveWindowForAuthCode(50); 

            if (string.IsNullOrEmpty(authCode))
            {
                throw new Exception("The authentication request was cancelled by the user.");
            }
            IAuthorizationState state = client.ProcessUserAuthorization(new Uri("http://localhost"), _authstate);
            return client.ProcessUserAuthorization(authCode, state);
        }

        // Now perform auth flow
        return null;
    }

    public void authenticate(){
            // Register the authenticator.                        
            var auth = CreateAuthenticator();
                 ps1 = new PlusDomainsService(new Google.Apis.Services.BaseClientService.Initializer()
                    {
                        Authenticator = auth
                    });
           if (ps1 != null)
                {

                    Google.Apis.PlusDomains.v1.PeopleResource.GetRequest grrrr = ps1.People.Get("me");

                    Google.Apis.PlusDomains.v1.Data.Person me = grrrr.Execute();

                if (me != null)
                {
                    //textBlock1.Text = "You successfully Authenticated!";
                   // textBlock2.Text =

                    Response.Write( "You successfully Authenticated!");
                   Response.Write("UserName: " + me.DisplayName + "\nURL: " + me.Url + "\nProfile id: " + me.Id);
                }
            }
    }

    string pollActiveWindowForAuthCode(int sleepTime)
    {
        string activeTitle = GetActiveWindowTitle();

        while (!activeTitle.StartsWith("Success code="))
        {
            activeTitle = GetActiveWindowTitle();
            Thread.Sleep(sleepTime);
        }
        //// strip to start of auth code
        string trimToAuthCode = activeTitle.Substring(activeTitle.IndexOf("=") + 1);
        return trimToAuthCode.Substring(0, trimToAuthCode.IndexOf(' '));
        //// trim the " - Google Chrome" text

        //while (!activeTitle.StartsWith("Success authuser="))
        //{
        //    //activeTitle = GetActiveWindowTitle();
        //    Thread.Sleep(sleepTime);
        //    trimToAuthCode = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();
        //}
        //  string trimToAuthCode = activeTitle.Substring(activeTitle.IndexOf("code=") + 1);
        //   return trimToAuthCode.Substring(0, trimToAuthCode.IndexOf(' '));
        // return trimToAuthCode;
    }

    private string GetActiveWindowTitle()
    {
        const int nChars = 256;
        IntPtr handle = IntPtr.Zero;
        StringBuilder Buff = new StringBuilder(nChars);
        handle = (IntPtr)GetForegroundWindow();

        if (GetWindowText((int)handle, Buff, nChars) > 0)
        {
            return Buff.ToString();
        }

        return null;
    } 

}

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

GoogleCodeExporter commented 9 years ago
1. Please regenerate new client secrets because they are exposed now for 
everyone...
2. Make sure your .NET framework is patched. Microsoft released patches to .NET 
to allow Portable Class Libraries to properly find the appropriate runtime 
(KB2468871). If you are seeing the above exception (or something like it), it 
means you're missing the latest .NET framework patches.

Let me know!
Thanks

Original comment by pele...@google.com on 10 Oct 2013 at 3:25

GoogleCodeExporter commented 9 years ago
Feel free to reopen this issue if is still happen.
Please be aware that the Google.Apis.Authentication isn't supported any more.
Use the Google.Apis.Auth which will make your life easier.

Original comment by pele...@google.com on 19 Jan 2014 at 9:52