Sunday, May 5, 2013

Private key information from the smart card


The way of getting the private key information from the smart card when it supports Microsoft CryptoAPI

using System.Security.Cryptography.X509Certificates;
usingSystem.Security.Cryptography;

public static X509Certificate2GetSignedCertificate()
{
X509Certificate2signingCert = null;
var myStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
var smartCardCerts = new List<X509Certificate2>();

myStore.Open(OpenFlags.ReadOnly);
foreach (X509Certificate2 cert inmyStore.Certificates)
       {
if (!cert.HasPrivateKey) continue;          


var rsa = cert.PrivateKey as RSACryptoServiceProvider;

if (rsa == null) continue
if (rsa.CspKeyContainerInfo.HardwareDevice) 
{
signingCert = cert;
myStore.Close();
return signingCert;
}
        }
   return signingCert;


}

Monday, November 5, 2012

EventRecord.FormatDescription() method returns nothing though it has data.



When using System.Diagnostics.Eventing.Reader.EventLogQuery to read events from the Windows Event Log, the EventRecord.FormatDescription() method returns nothing though it has data.
When I set the Current Culture, it starts to working.
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

Hope this will be helpful to anyone who comes across this issue.

Sunday, October 28, 2012

BizTalk 2010 - Hot Fix

I have installed the following Hot Fixes on my BizTalk environment to get rid of the following issues.

Issue:
  After editing one of the complex orchestrations, I could not build the project.
  mismatched 'braces' '{}' error appers on the build output.
Solution:
It worked fine after installing the   FIX: Build operation fails after you modify an orchestration of a BizTalk Server 2010 solution in Visual Studio 2010

Issue:
The following error came when deploying the changed BizTalk solution
Error saving map. Stored procedure returned non-zero result
Solution:
It worked fine after installing the FIX: "Error saving map. Stored procedure returned non-zero result." error message when you deploy the BizTalk Server 2010 applications in BizTalk Server 2010 Administration Console

Tuesday, October 23, 2012

Windows Schdule Task does not support Clustering on Windows 2008 r2

Windows Schedule Task does not support clustering on Windows 2008 r2 Failover Cluster. I have used BizTalk 2010 Scheduled Task Adapter (http://biztalkscheduledtask.codeplex.com/) as an alternative for this

Wednesday, October 17, 2012

issues when creating WCF proxy

I have changed my WCF services and updated the service reference on my test project.
But I could not build the project after that. Then I tried to build it on my old machine and it was built. So this should be an environment issue. I had the following errors & warnings in the output.

Custom tool warning: Cannot import wsdl:portType

Custom tool error: Failed to generate code for the service reference  

There are blogs which say I need to unclick the Reuse types in reference assemblies. But it didn’t work for me.  
Then I tried to run using the WCFStorm tool and I got the following errors

Metadata contains a reference that cannot be resolved: 'http://localhost:8082/Service.svc'.
Import Error : Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace


I found some blogs which says I need to repair ServiceModelReg & need to run aspnet_regiis.exe –iru. But anything didn’t help me.
Then I found the following link it says this is happening because of permission issues in c:\windows\temp
http://blogs.infosupport.com/unable-to-generate-a-wcf-proxy-using-svcutil-but-retreiving-the-wsdl-works/
Yes It was the issue of environment. Thank you for the above blog writer you have saved my time.