Prepare C# Application to Handle Restart Message

[http://msdn.microsoft.com/en-us/library/windows/desktop/hh749939.aspx]

[Apps must adhere to system restart manager messages]

4.1 Your app must handle critical shutdowns appropriately

In a critical shutdown, apps that return FALSE to WM_QUERYENDSESSION will be sent WM_ENDSESSION and closed, while those that time out in response to WM_QUERYENDSESSION will be terminated.

4.2 A GUI app must return TRUE immediately in preparation for a restart

WM_QUERYENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1).

Console apps can call SetConsoleCtrlHandler to specify the function that will handle shutdown notifications. Service apps can call RegisterServiceCtrlHandlerEx to specify the function that will receive shutdown notifications.

4.3 Your app must return 0 within 30 seconds and shut down

WM_ENDSESSION with LPARAM = ENDSESSION_CLOSEAPP(0x1).

At a minimum, app should prepare by saving any user data and state the information that is needed after a restart.

Advertisements

Import XSD to EA

Based on:

[http://bellekens.com/2013/04/30/simple-vba-excel-to-ea-importer-v3/]

Thanks to great integration capabilities of EA, VB for Applications is used to automate data transfer from Excel to EA (and vice versa)

The process consists of two steps:

  • XSD to Excel conversion
  • Excel to EA export

XSD to Excel conversion

Xsd2xls is a small program, converting complex XSD into flat XLS structure.

[Please email me for the download link]

Excel to EA export

Once XSD is already imported to Excel, it can be converted into EA objects.

Register EA OLE automation object in Excel

Samples can be found at [http://bellekens.com/2013/04/30/simple-vba-excel-to-ea-importer-v3/]

More samples to be added.

 

 

 

 

Signing C# application

This post is linking to the resources describing signing process of the C# application, that is using unsigned, 3rd parry libraries

[http://msdn.microsoft.com/en-us/library/6f05ezxy(v=vs.110).aspx]

How to: Create a Public/Private Key Pair

At the command prompt, type the following command:

sn –k <file name.snk>

 

[http://msdn.microsoft.com/en-us/library/ie/ms537364(v=vs.85).aspx]

Signing and Checking Code with Authenticode

[http://social.technet.microsoft.com/wiki/contents/articles/3281.introduction-to-the-microsoft-root-certificate-program.aspx]

[http://social.technet.microsoft.com/wiki/contents/articles/14215.windows-and-windows-phone-8-ssl-root-certificate-program-member-cas.aspx]

 

Install Root Certificate

[http://technet.microsoft.com/en-us/library/cc754841.aspx]

Administrators is the minimum group membership required to complete this procedure.

  1. To manage trusted root certificates for a local computer
  2. Click Start, click Start Search, type mmc, and then press ENTER.
  3. On the File menu, click Add/Remove Snap-in.
  4. Under Available snap-ins, click Local Group Policy Object Editor, click Add, select the computer whose local Group Policy object (GPO) you want to edit, and then click Finish.
  5. If you have no more snap-ins to add to the console, click OK.
  6. In the console tree, go to Local Computer Policy, Computer Configuration, Windows Settings, Security Settings, and then click Public Key Policies.
  7. Double-click Certificate Path Validation Settings, and then click the Stores tab.
  8. Select the Define these policy settings check box.
  9. Under Per user certificate stores, clear the Allow user trusted root CAs to be used to validate certificates and Allow users to trust peer trust certificates check boxes.
  10. Under Root certificate stores, select the root CAs that the client computers can trust, and then click OK to apply the new settings.

 

How to: Sign 3rt party dll

[http://buffered.io/posts/net-fu-signing-an-unsigned-assembly-without-delay-signing/]

  1. Disassemble dll

C:\Foo\bin> ildasm /all /out=Bar.il Bar.dll

  1. Assemble and sign dll

C:\Foo\bin> ilasm /dll /key=Foo.snk Bar.il