Web作业上的Windows Azure管理库认证错误

我构建了一个Azure Web作业控制台,它引用了Windows Azure管理库。 我尝试使用公共设置方法validation我的应用。 该程序在我的本地工作正常,但在使用X509Certificates错误的Azure Web作业上失败。 这就是我为网络工作计划所做的工作。 从https://windows.azure.com/download/publishprofile.aspx下载发布设置文件 在控制台应用程序上,通过从设置文件中复制并粘贴subscriptionId和cert字符串来创建凭证。 new CertificateCloudCredentials( subscriptionId, new 509Certificate2(Convert.FromBase64String(base64EncodedCertificate))); 在Azure Web Job上部署并尝试“按需运行”。 错误 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.X509Certificate..ctor(Byte[] data) at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData) 执行时出现exception: System.Security.Cryptography.CryptographicException, The system cannot find the file specified.

使用string和int数据类型在C#中创建列表

如何创建一个包含字符串值和int值的列表? 任何人都可以帮助我。是否可以创建具有不同数据类型的列表?

为什么使用System.Threading.Thread.Sleep()是一种不好的做法?

我正在编写一个应用程序,通过一个复杂的API处理一个庞大而丑陋的第三方系统。 有时系统会发生一些错误,但如果我们等待我的程序面对这些错误,那就太晚了。 所以,我使用一个单独的线程来检查系统状态如下: while (true) { ask_state(); check_state(); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); } 如果我在100毫秒或每分钟检查一次系统状态并不重要。 但我听说使用Thread.Sleep()是一种不好的做法。 为什么? 在这种情况下我该怎么办?

根据自签名证书颁发机构validation服务器证书

我有自定义服务器/客户端应用程序,使用SSL加密的TCP连接(自定义协议)相互通信。 为了设置服务器证书,我创建了一个自签名证书颁发机构,并使用它来签署证书供服务器使用。 在客户端,我想validation我连接的服务器的证书是由我的自签名CA签署的。 通过使用load_verify_file()函数为ssl :: context提供自签名CA证书,我能够在C ++中使用boost。 我想在C#客户端中实现相同的function,但.NET SSL的东西似乎要更加严格地信任不在Windows信任库中的证书。 到目前为止,我找到了几个部分解决方案。 显然, X509Chain是用于validationSSL证书的类 。 我尝试过这样的代码,但手动创建的链仍然抱怨根证书是不可信的,就像传递给validation函数的原始链一样。 有一个选项可以忽略未知的证书颁发机构 ,但这似乎意味着它将接受任何自签名证书,这绝对不是我想要的。 这是似乎最接近我想要的代码,但如上所述,我有一个问题,它仍然抱怨我添加到ExtraStore的证书是自签名的。 有没有办法说服X509Chain信任我给它的证书? bool remoteCertificateValidationCallback( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { // make sure certificate was signed by our CA cert X509Chain verify = new X509Chain(); verify.ChainPolicy.ExtraStore.Add(secureClient.CertificateAuthority); // add CA cert for verification //verify.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; // […]

选择查询以从SQL Server获取数据

我试图在我的C#代码中运行SQL Select查询。 但我总是得到-1输出 int result = command.ExecuteNonQuery(); 但是,如果我用于delete或insert工作相同的表… ConnectString也没关系。 请检查以下代码 SqlConnection conn = new SqlConnection(“Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=”); conn.Open(); SqlCommand command = new SqlCommand(“Select id from [table1] where name=@zip”, conn); //command.Parameters.AddWithValue(“@zip”,”india”); int result = command.ExecuteNonQuery(); // result gives the -1 output.. but on insert its 1 using (SqlDataReader reader = command.ExecuteReader()) { // […]

你如何找到呼叫者function?

作为“如何找到调用当前方法的方法?”的精确副本关闭。 这可能与c#有关吗? void main() { Hello(); } void Hello() { // how do you find out the caller is function ‘main’? }

在C#中执行包含GO语句的SQL批处理

我正在尝试构建一个程序,它在批处理中执行sql语句并进行error handling(因此我没有使用SMO)。 问题是GO不是SQL的一部分,当使用.NET执行语句时,它最终会出错(SMO会处理它但不会给出执行失败的任何指示)。 string statements = File.ReadAllText(“c:\\test.sql”); string[] splitted = statements.split(“GO”); 使用上面的行不能解决我的问题,因为GO关键字也可以进入注释(我不想从语句中删除注释)并且注释可以进入/ ** /或者在两个破折号之后 – 例如,我不希望解析以下代码: /* GO */ (ofc我谷歌搜索它,但那里没有解决方案)

Windows 10应用程序DownloadOperation无法启动

我试图在Windows 10通用应用程序上使用此代码下载文件: await downloadOperation.StartAsync().AsTask(token, progressCallback); 它在PC上运行但在移动设备上有时它不会开始下载,甚至在我重新启动移动设备之前都没有例外。 这是系统中的错误还是我遗漏了什么? 编辑1: 任务的状态是“等待激活”,因此它不会抛出exception。 它只是等待,直到我重新启动手机才开始我总是尝试使用相同的url,我在电脑上没有这个问题。 这只是关于手机的。 任务的属性如下:

在Windows 7中运行应用程序的证书问题

我的应用程序遇到了一些问题。 我正在使用’org.mentalis.security’程序集从’pfx’文件创建证书对象,这是发生exception的代码行: Certificate cert = Certificate.CreateFromPfxFile(publicKey, certificatePassword); 这一直在生产中并且仍在生产中,但由于某种原因,它在Windows 7中运行时抛出exception(在2台机器上试用)。 CertificateException : Unable to import the PFX file! [error code = -2146893792] 我通过Google找不到这条消息,但在查看事件查看器时,每次发生此exception时都会收到“审核失败”: Event ID = 5061 Source = Microsoft Windows Security Task Category = system Integrity Keywords = Audit Failure Cryptographic operation. Subject: Security ID: NT AUTHORITY\IUSR Account Name: IUSR Account Domain: NT AUTHORITY Logon […]

字段初始值设定项无法引用非静态字段,方法或属性

以下是我的代码: private BitsManager manager; private const string DisplayName = “Test Job”; public SyncHelper() { manager = new BitsManager(); } BitsJob uploadBitsJob = manager.CreateJob(DisplayName, JobType.Upload); 我收到以下错误: A field initializer cannot reference the non-static field, method, or property ‘BITSIntegrationModule.SyncService.SyncHelper.manager’