인 C# "invalid providertype"C# 전문가가 아니며 google api 및 서비스 계정이있는 첫 번째 프로젝트입니다. 내가 해결 방법을 모르는 문제가 생겼다. 이 코드는 2 대의 컴퓨터에서 작동하지만 3 번에는 작동하지 않습니다.Google 서비스 계정이
세 번째 컴퓨터가 실행하려고하면 잘못된 프로토 타입 오류가 발생합니다.
Documentation Google API - Service account
어떤 코드가 문제입니까?
사용 된 코드 :
string[] scopes = new string[] { AnalyticsService.Scope.AnalyticsReadonly };
var keyFilePath = System.AppDomain.CurrentDomain.BaseDirectory + "www.site.nl-.p12";
string serviceAccountEmail = "[email protected]";
string applicationName = "www.applicationname.nl";
string password = "notasecret";
//loading the Key file<br>
var certificate = new X509Certificate2(keyFilePath, password, X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = scopes
}.FromCertificate(certificate));
// setup the service
var service = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = applicationName
});
편집 (추가 스택 트레이스) :
Serverfout in toepassing /.
Ongeldig providertype opgegeven.
Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code.
Details van uitzondering: System.Security.Cryptography.CryptographicException: Ongeldig providertype opgegeven.
Fout in bron:
Regel 37: var certificate = new X509Certificate2(keyFilePath, password, X509KeyStorageFlags.Exportable);
Regel 38: var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
Regel 39: {
Regel 40: Scopes = scopes
Regel 41: }.FromCertificate(certificate));
Bronbestand: C:\inetpub\wwwroot\git\ttldashboard\ttldashboard\Helpers\GoogleAnalytics.cs Regel: 39
Stacktracering:
[CryptographicException: Ongeldig providertype opgegeven.
]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +5265821
System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +94
System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +136
System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +203
System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey() +240
Google.Apis.Auth.OAuth2.Initializer.FromCertificate(X509Certificate2 certificate) in C:\Users\cloudsharp\Documents\GitHub\google-api-dotnet-client\Src\Support\GoogleApis.Auth.PlatformServices_Shared\OAuth2\ServiceAccountCredential.cs:115
ttldashboard.Helpers.GoogleAnalytics.GetAnalyticsService() in C:\inetpub\wwwroot\git\ttldashboard\ttldashboard\Helpers\GoogleAnalytics.cs:39
ttldashboard.Helpers.GoogleAnalytics.GetGoogleExitClicks(Int32 locatieId, String startDate, String stopDate) in C:\inetpub\wwwroot\git\ttldashboard\ttldashboard\Helpers\GoogleAnalytics.cs:146
ttldashboard.Controllers.DashboardController.Index() in C:\inetpub\wwwroot\git\ttldashboard\ttldashboard\Controllers\DashboardController.cs:67
lambda_method(Closure , ControllerBase , Object[]) +87
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +229
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +67
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +386
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
Versiegegevens: Microsoft .NET Framework Versie:4.0.30319; ASP.NET Versie:4.6.1038.0
예외 (innerexception (s), stacktrace (s) 등)에 대한 자세한 내용을 게시 할 수 있습니까? –
작동하지 않는 컴퓨터에서 약간의 정보를 사용할 수 있습니다. @ JevgeniGeurtsen 우리는 던지는 예외를 모두 볼 필요가있다. – DaImTo
전체 스택 추적을 추가했습니다. 이것이 충분합니까? – xAndyx