C# 在测试服务器上的IIS中找不到文件异常/w3wp.exe问题,但在IIS Express中本地没有问题
我需要升级google API OAuth 2(但仍然使用一些旧的GData API)并几乎完全使用它,它通过iis express在本地运行非常好 为方便起见,代码为:C# 在测试服务器上的IIS中找不到文件异常/w3wp.exe问题,但在IIS Express中本地没有问题,c#,asp.net,debugging,iis,google-api,C#,Asp.net,Debugging,Iis,Google Api,我需要升级google API OAuth 2(但仍然使用一些旧的GData API)并几乎完全使用它,它通过iis express在本地运行非常好 为方便起见,代码为: using System; using System.IO; using System.Security.Cryptography.X509Certificates; using Autofac; using D.Core.Intelligence; using Google.Apis.Auth.OAuth2; using G
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using Autofac;
using D.Core.Intelligence;
using Google.Apis.Auth.OAuth2;
using Google.GData.Analytics;
using Google.GData.Client;
namespace D.Analytics
{
public class AnalyticsModule : Module
{
private const string ServiceAccountEmail = "3504f5u6sqlm@developer.gserviceaccount.com";
private static readonly string KeyPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath ?? AppDomain.CurrentDomain.BaseDirectory, "Key.p12");
private static readonly X509Certificate2 Certificate = new X509Certificate2(KeyPath, "notasecret", X509KeyStorageFlags.Exportable);
private readonly ServiceAccountCredential _credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(ServiceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/analytics" }
}.FromCertificate(Certificate));
protected override void Load(ContainerBuilder builder)
{
builder.Register(c =>
{
_credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Wait();
var service = new AnalyticsService("D.com");
var requestFactory = new GDataRequestFactory("razbot2.0");
requestFactory.CustomHeaders.Add(string.Format("Authorization: Bearer {0}", _credential.Token.AccessToken));
service.RequestFactory = requestFactory;
return service;
});
builder.RegisterType<AnalyticsNewsletterTrackingSource>().As<INewsletterTrackingSource>();
builder.RegisterType<AnalyticsSearchTrackingSource>().As<ISearchTrackingSource>();
builder.RegisterType<AnalyticsEmailLinkTracker>().As<IEmailLinkTracker>();
}
}
}
整个符号加载过程位于:
内部例外是:
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
at D.Analytics.AnalyticsModule..cctor()
留言:
The system cannot find the file specified.
与消息声明相反:文件的路径肯定是准确的,因为我已经通过调试点亲自检查过了。构建操作被设置为“content”和“copy if newer”,我甚至将.p12证书的值读入了bytearray,并将其输入到构造函数本身,但运气不好
这可能是因为我在代码中做了一些非常愚蠢的事情,而不是更深层的事情,但这让我很困惑,为什么它不在本地抛出任何异常
回答如上所述,还要写一句话,因为SO帖子的正文必须至少有30个字符。益母草
The system cannot find the file specified.