でC# "invalid providertype"が無効です。これは私の最初のプロジェクトで、Google APIとサービスアカウントです。私は解決する方法がわからないという問題に走っています。このコードは2台のコンピュータで動作しますが、3台目では動作しません。Googleサービスアカウント
3台目のコンピュータは、実行しようとすると、エラーのプロトタイプエラーが発生します。
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