In certain instances tests fail to run in Visual Studio 2005 when manipulating datasets after having installed Visual Studio 2008 on the same machine. Tests worked fine before Visual Studio 2008 was installed. The tests are done with MbUnit 2.4.197. I have tried experimenting with MbUnit 2.41.232 and Testdriven 2.10.2172, but it didn't make a difference.
What I get is the error "Common Language Runtime detected an invalid program". I have been trying different things and have found that uninstalling TypeMock fixes the issue and reinstalling TypeMock brings the issue back. Running the test in the MbUnit GUI always works fine, but with TestDriven.net in Visual Studio the error is thrown. TypeMock doesn't need to be used at all in the solution to produce the error. It is enough that TypeMock is installed.
This is on Vista X64. I have TypeMock with the x64 extra installed. TypeMock is v4.1.0.
The complete error:
Error 1 TestCase 'BrokenTest.CreateRowFilterFromViewTest' failed: Common Language Runtime detected an invalid program.
System.InvalidProgramException
Message: Common Language Runtime detected an invalid program.
Source: System.Data
StackTrace:
at System.Data.Index.GetEnumerator(Int32 startIndex)
at System.Data.DataView.ResetRowViewCache()
at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent)
at System.Data.DataView.UpdateIndex(Boolean force)
at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, IFilter newRowFilter, Boolean fireEvent)
at System.Data.DataView..ctor(DataTable table)
at BrokenTest.BrokenTest.CreateRowFilterFromViewTest() in C:Usershalstein.MERCATUS0DocumentsVisual Studio 2005ProjectsBrokenTestBrokenTestBrokenTest.vb:line 16 C:Usershalstein.MERCATUS0DocumentsVisual Studio 2005ProjectsBrokenTestBrokenTestBrokenTest.vb 16
The following code snippet demonstrates the error:
Imports MbUnit.Framework
<TestFixture()> _
Public Class BrokenTest
<Test()> _
Public Sub CreateRowFilterFromViewTest()
Dim dt As New DataTable
dt.TableName = "ScenarioUnit"
dt.Columns.Add("ScenarioUnitId")
Dim dr As DataRow = dt.NewRow
dr("ScenarioUnitId") = 1
dt.Rows.Add(dr)
Dim dv As DataView = New DataView(dt)
' .... crashes here so no more code included
End Sub
End Class