Could Not Create SSL/TLS Secure Channel is an error you my get when communicating with web services in a two way SSL scenario from ASP.NET application. Here is a guide which you can follow to resolve the issue. I spent fair bit of time on this and I am documenting my approach here for future reference.

Make sure that you have proper certificates installed in the Local Machine certificate store. Because communication is two way SSL you will also have your private key installed.

Because your communication occurs via ASP.NET application this is a permissions issue . Your ASP.NET applications runs under the identity configured in the App Pool. You must grant permissions to that account under which your application is running to access the private key. Here’s how to do it.

Download WinHttpCertCfg tool from this link. Don’t worry about the system requirement on the page. I was able to run the tool successfully on Windows 7. After installing the tool go to your command prompt and go to the directory where WinHttpCertCfg is installed. On my machine WinHttpCertCfg is installed at C:\Program Files (x86)\Windows Resource Kits\Tools.

Run WinHttpCertCfg using this command. Substitute “IssuedToName” with the appropriate name for your certificate and same for “AccountName”. If your App Pool runs under NetworkService then that’s the account you’ll put in.

WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s "IssuedToName" -a "AccountName"

This should take care of the permission issue and hopefully things will run as expected. In case this doesn’t work then investigate that your certificates are installed in the right store. I know you would have already done this but it doesn’t hurt to have another look. If all else fails then leave a comment and maybe I’ll also learn something new. In any case leave a comment :)

Tagged with:
 

This post shows you how to generate self signed certificates on Windows 7. To generate self signed certificates you must have IIS 7.5 installed because you will generate your certificate from within IIS manager.

Step 1

Launch IIS manager and in Filter type “Certificates” to see the Server Certificates Feature.

image

Step 2

Double click on Server Certificates feature and click on Create Self-Signed Certificate… in Actions panel on the right.

image

Step 3

Give your certificate a friendly name and click OK.

image

Congratulations you have just generated your self signed certificate. You can right click on the certificate you generated and export it to a file.

Tagged with:
 

I’ll come out clean on this. Lately I’ve been doing some Java and I have to say that the other side is not all that bad as it’s projected to be. Most of my Java work is around integration with .NET  and I’m lovin it.

My forays into Java and other non-Microsoft technologies is a post for another day. Today I just want to share some simple code which I wrote while I was struggling with a simple requirement. The requirement is to add x number of hours to current Date-Time.

I found that the best way to do this is by using Calendar class from java.utils package. Here is the code I wrote.

public static void main(String[] args) {

        // Create a new calendar object
        Calendar calendar = Calendar.getInstance();

        System.out.println(calendar);

        // Add 5 hours to current time
        calendar.add(Calendar.HOUR, 5);

        System.out.println(calendar);

    }

Each day as I work with Java I find things that seem interesting especially for a .NET guy. I’ll keep posting them.

Tagged with:
 

Hopefully most planet earth inhabitants know that Google pulled the plug on Wave or maybe most inhabitants who care about it. Together with my friend Graham we came up with these reasons for failure over a Japanese lunch today. Here’s the list.

  1. It did not ripple through masses.
  2. The tide was not on it’s side.
  3. It did not create waves in hearts or minds of people.
  4. The sail was in opposite direction.
  5. The product itself was shallow.

 

So it is finally time to wave it goodbye.

For the record this was getting way out of hand for our geeky minds and we were attracting unwanted attention at the restaurant. We decided to abandon the idea of coming out with more reasons.

Tagged with:
 

Back in 2008 I posted a suggestion on Microsoft’s Connect website. To be precise the date was 15th May 2008. To my surprise I received an email today (5th August 2010) informing me that there is a comment on my suggestion. It only took a little more than 2 years. Wow! talk about a speedy response. “What’s wrong with Microsoft” will be a topic for another post. Today I want to revisit my suggestion. It’s about Intellisense. Here it is exactly how I posted it on Connect site.

Problem Statement

At present we have Ctrl + . which opens intellisense and lists all methods, properties events available for the corresponding object. There are times when I and I assume other users are only interested in looking at either events, methods or properties.

Proposed Solution

I suggest the following shortcuts which will filter the list:
Ctrl + . + p – Display only properties
Ctrl + . + e – Display only events
Ctrl + . + m – Display only methods

And the response from Microsoft today is:

Thanks for taking the time to submit this suggestion! I sincerely apologize for the amount of time that has taken to get back to you.
When we locked down on our final feature set for the next version of Visual Studio, IntelliSense completion set filtering for member types didn’t make the cut–though it was considered. However, his is a commonly requested feature, and we’ll consider it for a future release of Visual Studio. Please feel free to contact me directly at … if you have any further thoughts.

I am glad to know that this will at-least be considered for a future release. I’ll be happy if it ever gets implemented.

Tagged with:
 

There are two things which I as a consultant / developer come across many times. One is verifying connectivity to a database which is often a cause of production issues and second is creating valid connection string in the least amount of time. This is the way I do it. Hopefully it will be of help to you.

First of all forget that you have Visual Studio, SSMS or anything so big and fancy. You just want to get a connection string baked up pronto. I usually end up creating a .udl file. UDL which stands for Universal Data Link allows you to establish a connection and then stores the connection string in text format. Doing this is very simple. Create a file in any folder or desktop and call it test.udl.

Now double click the file and you’ll get a window where you can enter your connection properties.

 image

You can also select different providers.

image

Once you have filled in the information about your server, security and database just click on Test Connection to verify connectivity. Click OK to close the window.

To get a connection string with information you just entered just open the test.udl file in a text editor and you’ll see the connection string.

 image

That’s it. Simple and easy ninja style.

Tagged with:
 

This post shows you how to find Data Providers installed on a machine. Data providers in .NET Framework provide the plumbing necessary to connect to databases. There are different data providers available which can connect to SQL Server, Oracle or other databases through OleDb. You can find the data providers installed on your machine by looking at Machine.config file. In particular you will be looking for DbProviderFactories element under System.Data. In the screenshot below you can see data providers installed on my machine.

image

A list of data providers can also be retrieved by code. This sample shows you how to retrieve a list of data providers in code.

DataTable dataProviders = DbProviderFactories.GetFactoryClasses();

foreach (DataRow provider in dataProviders.Rows)
{
  Console.WriteLine(provider[0].ToString());
}  

In the code above I am displaying the name of provider. Here is my output.

image

Tagged with:
 

A newer version of Visual Studio 2010 Productivity Power Tools has been released. If you use Visual Studio 2010 then do yourself a favor and download these power tools and use Visual Studio 2010 like a power user. Checkout all details at Visual Studio blog.

Download link for Productivity Power Tools.

Tagged with:
 

Visual Studio 2010 provides a nifty little feature which let’s you generate code from within the editor. In this post I will show you how to use this feature. Imagine that you are having a fantastic coding day and you are coding at 100mph. You have just realised that you need a class called car and you want to do it ninja style. Just type in this.

image

Visual studio displays Car in red because it cannot find a Type named Car. Put your cursor on Car and hit Ctrl + .

image

The smart tag gives you two options:

  1. Generate class for ‘Car’
  2. Generate new type…

If you select the first option, a new class is created for you in a new file and appropriately named Car.

The second option which is “Generate new type…” gives you more control over the code which will be generated.

image

In the dialog box you can choose Access (public or private) and you can also select if you’d like to generate a class, struct, interface or an enum. An option also exists down below to either add the newly generated code to an existing file or create a new file.

Pretty neat I think.

Tagged with:
 

Here is a step by step guide to turn on MSDTC on Windows 7. MSDTC settings are somewhat hidden in Windows 7 and I could not get to them as I did on Windows XP or Server 2003. I found a way and I’m putting it out here.

Step 1

Run dcomcnfg. This will open MMC with Component Services snapin.

dcomcnfg

Step 2

Expand Distributed Transaction Coordinator folder

image

Step 3

Right click on Local DTC and click Properties. Click on Security tab. Here you can modify DTC settings.

image

Tagged with:
 

This is one Machine to rule them all (I know Lord of Rings is so old school). In the Virtual Machine you will get the following.

  1. Windows Server 2008 R2 Standard Evaluation Edition x64, running as an Active Directory Domain Controller for the “CONTOSO.COM” domain with DNS and WINS
  2. Microsoft SQL Server 2008 R2 Enterprise Edition with Analysis, Notification, and Reporting Services
  3. Microsoft Office Communication Server 2007 R2
  4. Microsoft Visual Studio 2010
  5. Microsoft SharePoint Server 2010 Enterprise Edition
  6. Microsoft Office Web Applications
  7. Microsoft FAST Search for SharePoint 2010
  8. Microsoft Project Server 2010
  9. Microsoft Office Professional Plus 2010
  10. Microsoft Visio 2010
  11. Microsoft Project 2010
  12. Microsoft Office Communicator 2007 R2

So fireup your free download manager and download this absolute SharePoint 2010 nirvana. If you are contrained on bandwidth then just to let you know that full download will set you back by approximately 18GB.

Here is the download link.

Tagged with:
 

Running XP mode on Windows 7 requires Hardware Virtualization to be enabled. You set this through BIOS settings. But what if your machine does not support Hardware Virtualization. Yes such machines do exist and I have one. My SONY Vaio does not allow Hardware Virtualization. Why? Because it’s a SONY.

A good news for me and others who are in same boat is that Microsoft has released a patch which removes this requirement. Seriously, I cannot thank Microsoft enough for this. Good stuff guys, I owe you a beer.

Download the patch here.

Download patch for 64bit here.

Tagged with: