I want to write some blogpost about RhinoMocks. I made a TestProject in Visual Studio.Net 2008 to make some examples. The first thing I did was to add a reference to the RhinoMocks assembly. I made a test and it would not excute. This is all I got at first:

I did not understand why. I looked up more information about the testrun. This is what I found: The location of the file or directory ‘c:\users\<<user>>\documents\visual studio 2008\projects\rhinomocksdemos\rhinomocksdemos\bin\debug\Rhino.Mocks.dll’ is not trusted. Not trusted?! Its my computer. I downloaded it. I trust it. Windows is being stubborn (again). How can I solve this? Why does this happen?

As it turns out Windows (XP SP2 and above) is just being carefull. It adds a marker to a file downloaded from internet indicating that it may not be safe to execute it. Normally Windows will show a ‘Are you sure?’ dialog when you try to use the file. In my case it showed nothing obvious and left me in the dark. It would have been nice if Windows showed this error and the solution. It is a missed chance but then again I would not have anything to do if the world was perfect. The solution is simple: go to the properties of the file and click the unblock button on the General tab. Look at the screenshot below. Next click on the Apply button and then on the Ok button. The problem is solved. Testing and mocking can start.

 

 References:

http://social.msdn.microsoft.com/forums/en-US/vststest/thread/0d8d89d1-e373-4a29-9325-febf748a771c/ 

Ever have this error when you were building a master-detail view with the ASP.Net DetailsView and the GridView?

Server Error in ‘/’ Application.


Object must implement IConvertible.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement IConvertible.

 

I had. You know why? I will explain. It occurs when you use ObjectDataSources to create the master-detail view<< Er moet tussen dat de objectdatasource een methode als selectmethode gebruikt die een string verwacht en daardoor een IConvertible verwcaht>>. When you make the master-detail view the GridView DataKeyNames array contains the primary key fields of the table it displays. The DataKeyNames array is used the fill the SelectedValue property with the primary key value belonging to the row that is selected. The SelectedValue property is used as a parameter of the selectquery of the DetailsView’s ObjectDataSource. This way the GridView and the DetailsView are synchronized. The SelectedValue’s datatype must implement the IConvertible interface. I was using a Guid as the primary key field. A Guid does not implement the IConvertible interface. So the application blows up.

How can we use a Guid field as a primary key? 

Solution 1: use a guid as a parameter.

Solution 2: use the string but convert the guid to a string.