Wednesday, November 21, 2018

I take full responsability

Yes, I am the author of the post below.
Yes, I could not stand not deleting it.
Yes, my conscience obliged me to take record of it.

Wednesday, October 31, 2018

How to create Application Configuration files in .NET apps

I was getting mad while debugging my app - I could not find where a specific app.config appSetting key's value was coming from. I checked the machine config file to no avail.

I then simply followed exactly MSDN instructions regarding app.config file creation, and now the app setting key value is correct. Seems this is the way correct way to ensure you know exactly what your deployed config file will look like.

Don't forget to set the file's Build Action (Properties window) to Content. If you leave it as None, it will not be deployed.

Monday, October 29, 2018

Useful debugging tips for Visual Studio

Monday, September 3, 2018

Serialize C# DataTable

Read Xml

When using WritetoXml, do use the overload that requires a file path and writes the xml schema (XmlWriteMode.WriteSchema).
ReadXml will throw an exception saying it does not support schema inference from xml.
In addition, don't forget to set the datatable name with the same name the datatable that was used to write to xml.

Sunday, August 26, 2018

Preferred way to format fractional numbers in C#

double myDouble1 = 0.32;
double myDouble2 = 321.5235;

var currentCulture = CultureInfo.InvariantCulture.Clone() as CultureInfo;
var numberFormat = currentCulture.NumberFormat;
numberFormat.NumberDecimalDigits = 2;

Console.WriteLine(myDouble1.ToString("F", numberFormat));
Console.WriteLine(myDouble2.ToString("F", numberFormat));

Wednesday, August 15, 2018

JwtSecurityTokenHandler.ValidateToken throws exception and mentions setting IdentityModelEventSource.cs's ShowPII to true

Matthew Steeples here solved the mystery:

ShowPII is a static property, and here is how you can set it:
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;