This was not an easy one… I was trying to run a unit test with MSTest but I was always getting the following error:
Unit Test Adapter threw exception: Type is not resolved for member ‘XXX,XXX Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’
As usual in such case – a message which does not really say what’s wrong. I googled the problem but there was not much about it on the web. The best resource I found was post titled VSTS Unit Test ‘Type is not resolved’ exception. It describes how VSTestHost process runs the test and explains what the possible problem might be in this case.
The author suggests that data required for test (e.g. a dll file) is not found in base directory for AppDomain (i.e. unit test ‘Out’ directory) because it’s already switched back to directory that holds VSTestHost.exe. There are two links to MSDN given where Microsoft admits this is a known bug and provides a hack to work around the problem – supply VSTestHost with copies of required artifacts (again, this is described in details in above mentioned post).
Unfortunately that didn’t work with my case. I’ve found the root cause though…
Continue reading ‘MSTest: Unit Test Adapter threw exception: Type is not resolved for member XXX’
Published on
September 13, 2010 in
c#.
Tags: c#.
Microsoft recommends if you overload Equals method you should also overload GetHashCode. Now, how to properly implement GetHashCode? There are many resources on the web that describe it. A good starting point might be this article on Stack Overflow.
Following MSDN guidlines GetHashCode must fulfill these requirements:
- If two objects of the same type represent the same value, the hash function must return the same constant value for either object.
- For the best performance, a hash function must generate a random distribution for all input.
- The hash function must return exactly the same value regardless of any changes that are made to the object.
Sticking to first bullet, you (probably?) should consider the same fields in Equals and GetHashCode methods. Let’s have a look at the example in which I did so:
public class Contact
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public override bool Equals(object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}
// If parameter cannot be cast to Contact return false.
Contact c = obj as Contact;
if c == null)
{
return false;
}
// Return true if the fields match:
return ID == c.ID
&& FirstName == c.FirstName
&& LastName == c.LastName;;
}
public override int GetHashCode()
{
return ID.GetHashCode()
+ FirstName.GetHashCode()
+ LastName.GetHashCode();
}
}
Now, what is wrong with this example of GetHashCode? There’s one drawback here. The hash is calculated as a sum of three integer values, which might give a value that is greater than int.MaxValue and that will result in OverflowException.
Continue reading ‘C#: GetHashCode() might cause OverflowException’
A few days ago I decided to add ‘Donate’ button on my blog (see the sidebar to the right). This is a feature provided by PayPal.
If you want to prove you are really delighted with my help or simply you have too much spare money
, it’s possible to pay me a kind of tip. That can be a dollar or two, that’s not really important; every little helps. All in all that could help pay for the hosting.
Of course I’m still blogging for fun so treat this as a feature – use it only if you really want to
I’m sorry if you are an English spoken reader but this very post is published in Polish only. The reason for that is it describes issues related to Google Adsense and Polish tax law.
This blog is still supposed to be maintained in English so please do not get discouraged.
Wiadomym jest, że to osoba która zarabia w programie Google Adsense jest odpowiedzialna za sprawy podatkowe. W moim przypadku nie są to duże pieniądze, ale zacząłem się zastanawiać w jaki sposób mam postępować by nie mieć problemu z Urzędem Skarbowym.
Znalazłem ciekawy post Google Adsense – Podatki i jego kontynuację. Autor tego bloga wspomina dwa utarte schematy: (po szczegóły zapraszam do lektury tych dwóch postów, bo autor się postarał; ja tylko w skrócie):
- jeśli w danym miesiącu dostaniesz przelew z Google Adsense, masz czas do 20. dnia następnego miesiąca na zapłacenie podatku od tej transakcji; do końca kwietnia następnego roku wypełniasz PIT-36 (bo miałeś dochody z tzw. innych źródeł)
- wypełniasz PIT-36 (bo miałeś dochody z tzw. innych źródeł) i płacisz podatek od wypłaty z Google Adsense tylko raz, dopiero podczas składania deklaracji podatkowej za rok poprzedni
Continue reading ‘Jak zapłacić podatek za Google Adsense?’
Recently I’ve read a kind of summary post of my friend where he described his blog in numbers. I thought this is a great idea – those who follow a blog get more background on its existence.
Let me describe my blog in numbers, if you like:
- 27 months – first post was published on April 14th, 2007
- 148 posts
- 435 comments
- I started tracing visitors (with Google Analytics) on March 16th, 2008 (a year after first post) – 210,000 visitors ever since
- best referring sites: google search (172k visitors), dzone.com (3k), reddit.com (2.6k), bing search (2.5k), yahoo search (2.2k), stackoverflow.com (1.2k)
- 1 DZone Big Link: Exeptions and Errors in Java
- I have been invited to DZone?s Most Valuable Blogger lodge (more details)
Many thanks to all that have helped achieving these results. Thanks for thank-you comments, crutial remarks and suggestions to what I’ve published, and just visting my site.
Published on
August 18, 2010 in
books.
Tags: books.
Some time ago, DZone has introduced an interesting feature – DZone Refcardz. This is a collection of cheat sheets (111 items by now) on different topics, e.g. programming languages, developer tools and IDEs, development approaches and trends.

Cheat sheets will never replace books, full time trainings or tutorials – they are meant to be short and brief; supply the reader with the basics and summary; simple enough. You won’t learn the subject in details but DZone refcardz are worth giving a try.
I can see several usage models: (i) get a general meaning on a subject new to me (if I like it, then I go for it in details), (ii) refresh something, (iii) get back to it when in need of checking something quickly.
DZone Refcardz homepage: http://refcardz.dzone.com
Sending emails in C# is easy; for basic use cases you don’t need external resources to send a note because .NET BCL already ships it. On .Net Developer Center, there’s a short description how to do it.
Now, how to fetch the email? It turns out it is not that easy – it’s not supported by .Net BCL. I spent a while researching for the best library that matched my purposes and I want to share my views on a couple of components I looked at.
Note: Please bear in mind I was interested only in a small piece of functionality such library could provide. My need was only to fetch an email (in plain text) with attachments. That was supposed to be done via POP3. I was not really interested in features like advanced sending emails (e.g. email templates), request and delivery receipts, support for iCalendar, email in HTML, etc. To sum up, I did not test libraries from that angle and therefore this comparison will not suit needs of all developers.
Continue reading ‘Comparison of .Net libraries for fetching emails via POP3′
Visual Studio provides solid support for unit testing. One of the features are VSMDI files – test meta data file. The file is not much readable but Visual Studio comes with easy to use GUI for managing tests (grouping them in test lists, filtering, etc.).
All in all, VSMDI files are really helpful but…
- After a while there are several VSMDI files (MySolutionName1.vsmdi, MySolutionName2.vsmdi, MySolutionName3.vsmdi, …) in your project although only one is in use (and therefore added to source control). This is a known bug discovered in Visual Studio 2005. More information can be found there.
- Painful merging. Merging can be smooth or really painful. It is the latter with VSMDI. Sorry, with VSMDI there’s no such thing like merging. If you discover someone else has changed and checked in VSMDI file (conflict), just replace your local changes with server version and repeat your changes.
The reason for the mess here is each test is given ID which is a GUID which tends to change once in a while.
- Not runnable tests. This doesn’t happen too often but I’ve experienced it several times already. When you try to run some tests you are told they are not runnable because there are multiple tests with the same ID (again, IDs…) – see below. Of course you haven’t played with IDs…
At least this is an easy one (but not when you see that for the first time). Just refresh the whole test list view – select List of Tests in Test List Editor window and click refresh.
Ok, so that’s my list. Any points to add here?
A while ago, on April 6th, one of my posts, Exeptions and Errors in Java, became a DZone Big Link. As a result, the link was tweeted automatically and is available at DZone’s Twitter. I was really happy to be noticed in Web
But today I got pleased even more! I was noticed again; I received invitation to join DZone’s Most Valuable Blogger program. What it is, according to DZone:
DZone’s Most Valuable Blogger program brings together a group of highly talented bloggers, authors, and technologists actively writing about topics of interest to the developer community. These people are recognized in the industry for their contributions and deep technical knowledge on subjects ranging from software design and architecture to programming on a range of platforms including Java, .NET, Ruby and others.
You can see the list of MVBs at Meet the DZone MVBs. At the moment there are about 200 people listed and, as far as I have noticed, only a couple of them lives in Poland.
Update, 2010-07-12
I am now officially an MVB!
Update, 2010-07-23
Just got an MVB t-shirt too

It happened to me after connection to TFS was dropped. and I was moved to offline work mode. Default VSTS settings say whenever you start editing a file it will be automatically checked out and it will appear on Pending Changes window. However, after those connection problems I no longer experienced that behavior.
Solution
First of all it’s worth checking VSTS Source Control related settings according to this article. In my case everything was fine there.
The problem on my side was somewhere else. After I had gone offline I had to go online again (what a surprise?!). I was expecting that to happen after reconnecting to TFS, but that is not entirely true. What I had to do as well was use ‘Go online’ button at the top of solution explorer. Once pressed it listed all the files I had modified while in offline mode and VSTS started working as before.