Monday, December 22, 2014

Thursday, December 18, 2014

How to solve problem "Cannot find the requested object." while create an X509Certificate2 object?

It throws this exception for following line:
X509Certificate2 certificate = new X509Certificate2(@"c:\temp\server.pvk", "password");

It means: the certificate file is not valid.
The most common reason is:
Need pvkimprt tool to generate PFX files

This constructor creates a new X509Certificate2 object using a certificate file name and a password needed to access the certificate. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container.

Following are the steps to generate X509Certificate2

"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\makecert" -r -pe -n "CN=Test" -sky exchange c:\temp\server.cer -sv c:\temp\server.pvk -sr currentuser
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\cert2spc"  c:\temp\server.cer server.spc
pvkimprt -pfx server.spc server.pfx

Tuesday, December 16, 2014

In MS SQL, how to count total number of major objectsr, such as table, view, store procedure etc?

Select type_desc as Type, COUNT(*) AS Count from SYS.OBJECTS
group by type_desc

The Art of Programming

Thursday, December 11, 2014

What is the simplest way to solve "Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on"

Code Example


C# Naming Conventions with example

use PascalCasing for class names and method names.
use camelCasing for method arguments and local variables
use noun or noun phrases to name a class.
prefix interfaces with the letter I.  Interface names are noun (phrases) or adjectives.


Wednesday, December 10, 2014

How to list all of listening ports in Windows command prompt?

netstat -anb | findstr /R /C:"[LISTENING]"

How to solve problem "No connection could be made because the target machine actively refused it"

#1 reason is: target machine TCP not listening.
Can run following command line to check:
netstat -anb

What is difference between and is localhost. Only same machine can access this address.
But means all of ip addresses binding to this machine.


Workflows of Refactoring

Uri Templates

        var url = new UriTemplate("{tenant}/customers")
            .AddParameter("tenant", "acmé")

        Assert.Equal("", url);

Monday, December 8, 2014

5 Incredible Features in the Visual Studio 2015 Preview

Friday, December 5, 2014

How to solve Invalid Xml syntax error after updated an older Visual Studio project

Error message:
This application has failed to start because the application configuration is incorrect. Review the manifest file for possible errors.
Reinstalling the application may fix this problem. For more details, please see the application event log.

In EventView, the error message is:
Activation context generation failed for XXXXX
XXXX on line 1. Invalid Xml syntax.

The first line in config file is
<?xml version="1.0" encoding="Windows-1252"?>

Change to
<?xml version="1.0" encoding="utf-8"?>

Wednesday, December 3, 2014

Free browser base UML modelling tool

How many kind of UML diagrams in total?

Class Diagram
Component Diagram
Deployment Diagram
Object Diagram
Package Diagram
Profile Diagram
Composite Structure Diagram
Use Case Diagram
Activity Diagram
State Machine Diagram
Sequence Diagram
Communication Diagram
Interaction Overview Diagram
Timing Diagram

Tuesday, December 2, 2014

How to install SQL Server management studio only?

On the download page:

Select the file just for SQL Server management studio installation:

How to get list of SQL Server instances on local machine?

In command line prompt (Run as admin):
reg query "HKLM\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL"