May 25 2007

MBUnit unittest framework

Category: C#fossmo @ 05:10

I have resently switched from NUnit to MBUnit. One problem in MBUnit, when trying to run a test which uses System.Windows.Window object, was that the thread does not run as a STA thread. I got this error message: "The calling thread must be STA, because many UI components require this."

Example:
[Test]
public void Common_CheckIfListReturnsElement()
{
Window window = new Window();
}

It turns out that MbUnit overrides the ApartmentState, setting it to MTA by default. So you do need to specify the ApartmentState in the fixture attribute:

[TestFixture(ApartmentState = ApartmentState.STA)]
Problem solved!

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

May 6 2007

Microsoft Visual C# codename "Orcas" Express Edition

Category: C#fossmo @ 10:21
I was trying out Microsoft Visual C# codenam "Orcas" Express Edition the other day. When trying to create a WPF Application I got this error:
The project file 'C:\Documents and Settings\(Username)\Local Settings\Temp\vay1mynp.olr\Temp\(Application name).csproj' cannot be opened.

After searching around on the net for some minutes, I found a workaround. I had to go to this directory C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE and run this command regsvr32.exe ProjectAggregator.dll from the command prompt.

After doing this, the WPF Application template worked.


Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5