hotkeys for totalcommander

ALT + F5  - create archive

ALT + f6 -  unzip

at element [..] Shift + F6  - edit path to current folder

c# Revocate certificate in CA using CERTADMINLib

1 Add certadmin lib
enter image description here
For this install http://www.microsoft.com/en-us/download/details.aspx?id=7887

Follow these steps:
1.        Click Start , click Control Panel , and then click Programs .
2.        In the Programs and Features area, click Turn Windows features on or off .
If you are prompted by User Account Control to allow the Windows Features dialog box to open, click Continue .
3.        In the Windows Features dialog box:

Expand Remote Server Administration Tools .
Expand Role Admin Tools .
Expand Active Directory Certificate Services Tools .
Check Certificate Authority Tools.
OK.

In command prompt type this: "tlbimp certadm.dll"

Usefull links about this
http://blogs.msdn.com/b/alejacma/archive/2012/04/04/how-to-get-info-from-client-certificates-issued-by-a-ca-c-vs-2010.aspx
https://social.technet.microsoft.com/forums/windowsserver/en-US/cf809bb4-f172-46f3-86f8-36e43be89a1d/error-adcs-revoke-a-certificate-using-certadminlibdll

2 Use this code
public static void RevokeCert(string connection,string serial)
{
    //connection= "192.168.71.128\\My-CA"
    //serial = "614870cd000000000014"

    const int CRL_REASON_UNSPECIFIED = 0;

    CERTADMINLib.CCertAdmin _admin = null;
    try
    {
        _admin = new CCertAdmin();
        _admin.RevokeCertificate(connection, serial, CRL_REASON_UNSPECIFIED, DateTime.Now);
    }
    finally
    {
        if (_admin != null)
            Marshal.FinalReleaseComObject(_admin);
    }
}

How to automatically run tests c#

NUnit

For nunit there is a very usefull decision NUnit-Console

http://www.nunit.org/index.php?p=consoleCommandLine&r=2.2.5

Using different parametres you can watch results in text or xml file.

For example

nunit-console /xml:console-test.xml nunit.tests.dll

MSTest

For MSTEST there is same tool named mstest
Example
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest" /testcontainer:"D:\TeamCity\buildAgent\work\8a4449e52545215c\web\MvcApplication2\MvcApplication2.Tests\bin\Release\MvcApplication2.Tests.dll" /test:AboutTest 

You can choose wich of tests to run by using param /test

Compiling projects without Visual Studio

1 Create bat file in c:\bin\msbuild.bat

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild %1

@echo off

if errorlevel 1 (
    pause
    exit
)

    pause

2 In notepad++ press F5 and input folowing text (or Run->Run in menu)

C:\bin\msbuild.bat "$(FULL_CURRENT_PATH)"

3 Open sln file, press F5 and enter then


4 Your Code is compiled successfully

It's possible to choose configureation option

msbuild /property:Configuration=Release MyFile.vbproj

Usefull link to stackoverflow http://stackoverflow.com/questions/18286855/how-can-i-compile-and-run-c-sharp-program-without-using-visual-studio


visual studio shortcuts



Shortcut for turning on line numbers


How to Register ActiveX/COM dll in order to use with c#


If the DLL is 32 bit:
Copy the DLL to C:\Windows\SysWoW64\
In an elevated command prompt: %windir%\SysWoW64\regsvr32.exe %windir%\SysWoW64\namedll.dll
if the DLL is 64 bit:
Copy the DLL to C:\Windows\System32\
In an elevated command prompt: %windir%\System32\regsvr32.exe %windir%\System32\namedll.dll
I know it seems the wrong way round, but that's the way it works. See:
http://support.microsoft.com/kb/249873
Quote: "Note On a 64-bit version of a Windows operating system, there are two versions of the Regsv32.exe file:
The 64-bit version is %systemroot%\System32\regsvr32.exe.
The 32-bit version is %systemroot%\SysWoW64\regsvr32.exe.

In order to solve next problem you have to run cmd as an Administrator
“The module “%1″ was loaded but the call to DllRegisterServer failed with error code 0×80004005. For more information about this problem, search online using the error code as a search term”.




json

var res = (YourClass)Newtonsoft.Json.JsonConvert.DeserializeObject(s, typeof(YourClass));

string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(o);