CrypTool – understanding cryptography with examples

One of the sessions I liked most on Microsoft Technology Summit 2011 was one delivered by Krzysztof Bińkowski – it was about certificates and PKI in context of Windows Server 2008. I’m not going to describe the session here, but wanted to share the tool that might help better understand the world of cryptography.

To better explain theory provided on his slides, Krzysztof used CrypTool. Let me cite the authors of this tool to give you a basic idea on what CrypTool is:

CrypTool is a free, open-source e-learning application, used worldwide in the implementation and analysis of cryptographic algorithms. It supports both contemporary teaching methods at schools and universities as well as awareness training for employees and civil servants.

Continue reading ‘CrypTool – understanding cryptography with examples’

Book review: LINQ Unleashed for C#

linq unleashed Book review: LINQ Unleashed for C#

I find this book relevant and very informative. If you want to master LINQ lingo, just read it.

For broader evaluation see my review on DZone.

P.S. DZone’s IT Book Zone is another great initiative. In short DZone gives you a free copy of a book and expects to receive its review in return. Fair agreement – one can stretch the envelope of IT domains for free, while DZone broadens thier public resources.

MSTest: Unit Test Adapter threw exception: Type is not resolved for member XXX

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’

C#: GetHashCode() might cause OverflowException

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’

It’s possible to support this blog

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 icon smile Its possible to support this blog , 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 icon smile Its possible to support this blog

Jak zapłacić podatek za Google Adsense?

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):

  1. 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ł)
  2. 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?’

Celebrating 2.5 years and 210,000 visitors to my blog

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.

DZone Refcardz: Cheat sheets for developers

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.

27343 DZone Refcardz: Cheat sheets for developers

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

Comparison of .Net libraries for fetching emails via POP3

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: Common problems with VSMDI files

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…

  1. 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.
  2. 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.

  3. 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…
    notrunnable 350x83 Visual Studio: Common problems with VSMDI files

    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?