Solved: The destination thread no longer exists exception – C#

2016-11-08 You will get System.ComponentModel.InvalidAsynchronousStateException (The destination thread no longer exists.) if a UI component gets disposed or the UI thread EXITs while a different thread is in the middle of invoking a change on the same UI component. This usually happens when a user closes a window (form) that has been updated by aContinue reading “Solved: The destination thread no longer exists exception – C#”

Using multiple versions of Entity Framework in the same solution

2016/07/20 Using multiple versions of Entity framework by different projects within the same solution. I had to develop a pilot project to use Entity framework (EF) 6.0 inside the solution that already has other projects that refers to EF 4.4. While debugging I received this error: Could not load file or assembly ‘EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’Continue reading “Using multiple versions of Entity Framework in the same solution”

SQL Server data types explained with .net data types

2016/07/19 Source / Reference : Msdn Member name Description BigInt Int64. A 64-bit signed integer. Binary Array of type Byte. A fixed-length stream of binary data ranging between 1 and 8,000 bytes. Bit Boolean. An unsigned numeric value that can be 0, 1, or null. Char String. A fixed-length stream of non-Unicode characters ranging betweenContinue reading “SQL Server data types explained with .net data types”

SQL to Generate C# Properties from SQL Table Columns

2016/07/15 Below SQL will generate C# properties for all columns in a table in SQL server. Notes: You will have to fix datatypes that are not interchangeable between SQL and C#. You will also have to polish property names if you follow a different naming convention for column names. The query below automatically renames someContinue reading “SQL to Generate C# Properties from SQL Table Columns”

C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values

2016-07-06 Code below will search for a given named property, field, or method inside a given object. It will search in below order: Properties Fields Methods It will continue to search until it finds a match that holds or returns (for methods) a non-null value. E.g. If you searched for “Name” and if there is a propertyContinue reading “C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values”

Stop asp.net from encoding the source HTML string (mvc raw html)

/// Stops asp.net from encoding the source HTML string. public static IHtmlString HTMLRaw(string source) { return new HtmlString(source); } call this function whenever you want asp.net NOT to encode the string. Note: You can use <%= and %> tags to avoid encoding as well. Menol ILT

How to Add/Update/Remove Application Configuration (App.Config) Keys

14/05/2013 How to add new keys to app.config file? Simple, just use this code. When you execute this code, a new key will be added to your configuration file and the given value will be set for it. Important: This code will not change the configuration file you see in the Visual Studio but theContinue reading “How to Add/Update/Remove Application Configuration (App.Config) Keys”