Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

InvalidProgramException on certain tests in solution
BrendanBurns
#1 Posted : Friday, September 30, 2011 4:43:54 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/30/2011(UTC)
Posts: 1
Location: Melbourne

Hi all,

I just downloaded NCrunch 1.34b and enabled it on a rather large Visual Studio 2010 solution with hundreds of NUnit tests.

On quite a few tests I am see an exception, "System.InvalidProgramException : Common Language Runtime detected an invalid program.".

However, the tests run successfully when I run them using Resharper 6.

Has anyone seen this problem before?

Cheers,
Brendan
Remco
#2 Posted : Friday, September 30, 2011 7:34:18 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,140

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Brendan,

This sounds like an instrumentation problem. There's been a few of these floating around.

Usually this is caused by interesting/rare IL arrangements that get messed up when NCrunch processes an assembly after it's been built. You'll probably find that there's one method that is causing it.

Is there any chance you may be post any details about the method where this is happening? This can help me to figure out what is unique about it that is causing NCrunch to fail.


Cheers,

Remco
MetaSam
#3 Posted : Wednesday, December 7, 2011 4:38:18 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/7/2011(UTC)
Posts: 7

Was thanked: 1 time(s) in 1 post(s)
I have a similar problem. I sent one case with the bug report tool. In this case the code which had the error was long and complicated, but I could narrow it down to:

Quote:
Private Class SomeClass
Public Property SomeIntProperty As Integer
Public Property SomeOtherIntProperty As Integer
Public Property SomeBooleanProperty As Boolean
Public Property SomeStringProperty As String
End Class

Private Sub Test()
Dim someUnusedVar As Integer

Dim dict As New Dictionary(Of String, List(Of SomeClass))
Dim enumerable As IEnumerable(Of SomeClass)

Dim anotherUnusedVar As Integer
For Each enumerableItem In enumerable
Dim list As List(Of SomeClass)

For Each listItem In list
Dim oneMoreUnusedVar As Integer = 3
Dim cl As New SomeClass
If 1 >= cl.SomeIntProperty Then
Dim otherObj As New SomeClass
otherObj.SomeIntProperty = 0
otherObj.SomeBooleanProperty = (1 <= cl.SomeOtherIntProperty)
dict(enumerableItem.SomeStringProperty).Add(otherObj)
End If
Next
Next
End Sub


If I remove any of the unused vars, I don't get the error anymore. Weird.
MetaSam
#4 Posted : Wednesday, December 7, 2011 6:05:13 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/7/2011(UTC)
Posts: 7

Was thanked: 1 time(s) in 1 post(s)
Here's another isolated method which fails with the same error:

Quote:
Private Class SomeClass
Property SomeDoubleProp As Double
End Class

Private Sub Test()
Dim myList As New List(Of SomeClass)
Dim unusedBoolValue As Boolean = False
Dim intValue As Integer

If (intValue > 0) Then
Dim doubleValue As Double = 0.0
Dim index As Integer = 0
While (index < myList.Count)
If (index <> 0) Then
doubleValue += myList(index).SomeDoubleProp
End If
index += 1
End While
End If
End Sub
Remco
#5 Posted : Wednesday, December 7, 2011 9:16:27 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,140

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Excellent! Thank you ... it's not always easy to reproduce these problems. I'll take a look at this and will see if I can get a fix introduced.
Remco
#6 Posted : Thursday, December 8, 2011 10:42:09 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,140

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
It looks like this was being caused by a certain IL arrangement that the instrumentation didn't handle too well. You can probably work around it by splitting this code up into smaller methods or by turning off the instrumentation. A fix for this issue will be in the 1.36b release, due out before Christmas.
MetaSam
#7 Posted : Thursday, December 8, 2011 4:11:39 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/7/2011(UTC)
Posts: 7

Was thanked: 1 time(s) in 1 post(s)
I'll try to work around it in the meantime by splitting into smaller methods (in 2 out of 3 cases, this is needed anyway, these methods are too long!).

Thanks a lot and keep up the good work!
Remco
#8 Posted : Monday, December 19, 2011 8:08:51 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,140

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
The fix for the above problem has now been released as part of 1.36b.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.061 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download