Wednesday, February 29, 2012

LINQ: "MSDTC on server is unavailable"

"MSDTC on server 'server name' is unavailable" - sometimes you get this exception while using LINQ to SQL. It means that service called "Distributed Transaction Coordinator" is currently disabled on your server. It is easy to turn it on, but what is wrong with the code, if you get such exception?

Monday, February 27, 2012

Windows: mysterious folders

A few days ago i faced a simple task related with xml parsing. Generally speaking, it was about parsing a bunch of files (around 20 thousand) containing information about domains. This information should be stored into MSSQL database. The situation was the following: those xml files were created under linux os. Each file name matched the following pattern: [domainname].[domainzone].xml and they were sent to me in a .zip archive. So i wrote a simple script, iterating through all .xml files in folder, fetching the data within linq to xml and inserting in in a proper tables. I left this script working and gone to have a coffee.

When i came back i realized, that one single file was missing. The domain name was "aux", and after unzipping the file name appeared to be [_aux_].[_domainzone_].xml_ Something like this - containing underscores. No problem, i decided to rename it and run the script again, but the cursed file refused to be renamed.

I googled this problem and found the answer. The problem is that Windows has some restricted file names, such as for example aux, com, con, prn, nul and others. So it is not possible to create files or folders with such names. I decided to check one more guess: i navigated to this web site and tried to save the web page using my browser. No surprise that I saw a warning.

Thursday, February 16, 2012

Visual Studio: Build vs Rebuild

Visual studio allows to build or to rebuild either solution or single project.

And sometimes i face a common question: what is the difference between those two options?

Both Build and Rebuild commands used for compiling and linking source files. But in case of Build only files, that have been changed since last build will be compiled and linked, the rest will be untouched.

In case of Rebuild ALL the files will be compiled, regardless of whether they have been changed or not since the last build.

The build is definetely faster and could be used if you are sure, that for example the reference files or libraries wasn't changed.

Wednesday, February 15, 2012

LINQ: way to remove duplicate items in the collection

A few days ago I was faced with the need to remove duplicate items from the collection. And I found several ways to solve this problem.