Skip to content

Tag Archives: C#

System.InvalidOperationException – Cross-thread operation not valid

05-Feb-10

System.InvalidOperationException – Cross-thread operation not valid: Control ‘xxxxx’ accessed from a thread other than the thread it was created on. Normally we get this exception when we try to modify some control property from another thread. This is because when a program executes the operating system will assign a thread for the creation of UI [...]

Isolated Storage in C#

03-Feb-10

As I am working in a Windows Application, client asked about the Windows 7 and Windows Vista compatibility. As I was writing only managed code I was not worried about the compatibility and most of the time it was working fine. (I was using Windows Vista). Today evening one of my colleague was testing the [...]

Writing File with Non Cache mode in C#

19-Jan-10

Normally when we are writing to the File Systems or I/O devices, Windows will cache the request or response to get better performance. This behavior is a good feature, but sometimes we require immediate change. By caching Windows sometimes mislead us. And I don’t think there is a way to avoid this option available in [...]

Exploring IL Assembler

18-Jan-10

One of colleague once asked a question to me, like what is the risk by distributing the windows application without obfuscating it. The only problem I found is user can use some tools like .Net Reflector and explore our assemblies. But few days before I found some nice .Net Framework tools, ildasm.exe and ilasm.exe, IL [...]

Enumerating Instances of SQL Server using C#

18-Dec-09

One of the project I am worked, I had to enumerate SQL Server instances of the network for creating dynamic connection string. Here is a code snippet which will retrieve all the SQL Server instance in a network using C# and ADO.Net.

using System.Data;
using System.Data.Sql;

SqlDataSourceEnumerator sqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance;
DataTable sqlServerInstances = sqlDataSourceEnumerator.GetDataSources();

The Data Table contains 4 columns, [...]