Search

Tutorials, tips&tricks, snippets..

K.I.S.S.: Keep It Simple, Stupid!

Category

Miscellaneous

Fast and useful hint to analyze your disk usage

Just click here and discover the power of WinDirStat. If you have a full disk to clean up, this will be your savior.

Advertisements

CopyDatabaseWizard version error

This morning I found this annoying message in Event Viewer of my machine where I have a SQL Instance:

Activation context generation failed for “c:\program files (x86)\microsoft sql server\120\Tools\Binn\managementstudio\CopyDatabaseWizard.exe”.Error in manifest or policy file “c:\program files (x86)\microsoft sql server\120\Tools\Binn\managementstudio\CopyDatabaseWizard.exe” on line 8. The value “1.0” of attribute “version” in element “assemblyIdentity” is invalid.

A quick solution is:

Continue reading “CopyDatabaseWizard version error”

What is the difference between Public, Private and Protected?

We always see the Access Modifiers in our code, but do we really know them?

Continue reading “What is the difference between Public, Private and Protected?”

Extension Methods #4: check if object has a property

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #4: check if object has a property”

Extension Methods #3: get property name starting from its own name

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #3: get property name starting from its own name”

Extension Methods #2: toString with NULL values

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #2: toString with NULL values”

Extension Methods #1: truncate a string

We have a lot of confortable methods ready to use in our .NET objects and this is wonderful: just think for example the method .toString()! How much do we use it? But, sometimes, these methods aren’t enough and we need to create others on our own.

Continue reading “Extension Methods #1: truncate a string”

Generate random strings

private static Random random = new Random();
public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
        .Select(s => s[random.Next(s.Length)]).ToArray());
}

Parsing a JSON string in C# without creating a dedicated class

JSON is a very useful format, able to stringify all your data. It is based on the key:value pattern and it a JSON value can contains a JSON structure itself.

How can we parse a JSON string and use it like an object in C#, without having a destination class? With the following code, we are able to navigate a JSON string without defining a class for it.

Continue reading “Parsing a JSON string in C# without creating a dedicated class”

Blog at WordPress.com.

Up ↑