Wednesday, May 11, 2016

Cool Code Editor From Microsoft

I just got this news from one of teammate this morning, Microsoft release a coding tool call Visual Studio Code, which is completely free.

you can download Visual Studio Code from this page

https://code.visualstudio.com/


I posted the screen shot after my installation.




please always remember this useful short cut Ctrl+Shift+P to launch Extension Manager



then you can install all kind of features that require for your own development.


How to set the specific duration time for schedule task

you might be confused by the dropdown list on the For a durant of selection in the trigger window on the schedule task configuration.

we think that we only allow to select from the drop down list to make our choice.





In my case, I need to configure the schedule task to run on sunday from 12:00 AM unitl 8 PM at night. which is 20 hours in total. none of the item meet my criteria in the drop down.

the trick is to select either 12 hours from the dropdown list, then put a focus o the dropdown list control, then change 12 to 20, now the schedule task will be execute for 20 hours on every Sunday.

Tuesday, May 3, 2016

How to encrypt and decrypt configuration sections in app.config of window or console application with script

It is quite easy to encrypt web.config file in the web application. since Microsoft did provide us the tool (ASP.NET IIS Registration Tool (Aspnet_regiis.exe)) to get the job done.

you can simple run the following line in the CMD window to encrypt the connectionString sections in web.config file

I copied the below command line from MSDN Encrypting and Decrypting Configuration Sections
 
aspnet_regiis -pe "connectionStrings" -app "/SampleApplication" 
-prov "RsaProtectedConfigurationProvider"

the above commend line with encrypt the connection string section with RsaProtectedConfigurationProvider.

However the configuration file of window or console application is app.config. ASP.Net IIS Registration Tool will not work in this case. However there is  work around. we can simply rename the app.config to web.config file, then run the encrypt command. Finally we rename web.config file back to app.config.

 Script encrypt the app.config file


copy App.Config App.Config.Encrpytoriginal
rename App.config web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pef connectionStrings . -prov DataProtectionConfigurationProvider
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pef appSettings . -prov DataProtectionConfigurationProvider
rename web.config App.config

Script to decrypt the app.config file

del App.Config.Decryptoriginal
copy App.Config App.Config.Decryptoriginal
rename App.config web.config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pdf connectionStrings . 
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pdf appSettings . 
rename web.config App.config

you can save those scripts into two different batch files, and place them in your app project folder.

as a result, you can encrypt and decrypt in your configration section in the fly.