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

Notification

Icon
Error

RavenDB: System.InvalidProgramException : Common Language Runtime detected an invalid program
graduss
#1 Posted : Thursday, June 19, 2014 1:32:35 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/19/2014(UTC)
Posts: 5
Location: United Kingdom

Hi,

all my RavenDB tests throwing "System.InvalidProgramException : Common Language Runtime detected an invalid program"
when attempting to execute raven index running under NCrunch. Stack trace snapshot below

System.TypeInitializationException : The type initializer for 'ICSharpCode.NRefactory.CSharp.AstNode' threw an exception.
----> System.InvalidProgramException : Common Language Runtime detected an invalid program.
at ICSharpCode.NRefactory.CSharp.AstNode..ctor()
at ICSharpCode.NRefactory.CSharp.EntityDeclaration..ctor()
at ICSharpCode.NRefactory.CSharp.TypeDeclaration..ctor()
at Raven.Database.Linq.DynamicViewCompiler.TransformQueryToClass() in c:\Builds\RavenDB-Stable\Raven.Database\Linq\DynamicViewCompiler.cs:line 51
at Raven.Database.Linq.DynamicViewCompiler.GenerateInstance() in c:\Builds\RavenDB-Stable\Raven.Database\Linq\DynamicViewCompiler.cs:line 594
at Raven.Database.Storage.IndexDefinitionStorage.AddAndCompileIndex(IndexDefinition indexDefinition) in c:\Builds\RavenDB-Stable\Raven.Database\Storage\IndexDefinitionStorage.cs:line 233
at Raven.Database.Storage.IndexDefinitionStorage.CreateAndPersistIndex(IndexDefinition indexDefinition) in c:\Builds\RavenDB-Stable\Raven.Database\Storage\IndexDefinitionStorage.cs:line 180
at Raven.Database.DocumentDatabase.PutIndex(String name, IndexDefinition definition) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:line 1207
at Raven.Client.Embedded.EmbeddedDatabaseCommands.PutIndex(String name, IndexDefinition definition, Boolean overwrite) in c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddedDatabaseCommands.cs:line 429
at Raven.Client.Indexes.AbstractIndexCreationTask.Execute(IDatabaseCommands databaseCommands, DocumentConvention documentConvention) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Indexes\AbstractIndexCreationTask.cs:line 198
at Raven.Client.DocumentStoreBase.ExecuteIndex(AbstractIndexCreationTask indexCreationTask) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\DocumentStoreBase.cs:line 91

Tried different suggestions from this post http://forum.ncrunch.net...an-invalid-program.aspx
but nothing helped.

Appreciate any advice on the issue.

Thanks
Remco
#2 Posted : Thursday, June 19, 2014 10:25:44 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

Is the ICSharpCode project included in your solution? Or is this an assembly (DLL) you are referencing?

Do you have a profiler based mocking framework installed such as TypeMock or JustMock?

It's worth checking to see if this is related to the bitwise architecture of the test process NCrunch is using to execute your code. Make sure that the x86/x64 is consistent between the NCrunch test runner and any other test runner you may be using. You can find more details about the differences here - http://www.ncrunch.net/documentation/troubleshooting_x86-x64-platform-issues.

Something else you can try is to put your solution in 'Compatbility mode' - http://www.ncrunch.net/documentation/troubleshooting_compatibility-mode. This is a great way to diagnose the issue as it will tell us if the problem is being caused by a specific NCrunch feature, or something more general.


Cheers,

Remco
graduss
#3 Posted : Friday, June 20, 2014 1:14:25 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/19/2014(UTC)
Posts: 5
Location: United Kingdom

Hi Remco

I tried your suggestion turning on compatibility mode but still getting the same errors. ICSharpCode is referenced as an existing assembly.
I'm using TypeMock (7.4.2.86) which will be removed later on. Nothing fancy with platform settings. Any CPU for the test project and NUnit
settings synced with test proj.

Thanks
Remco
#4 Posted : Friday, June 20, 2014 11:05:30 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks, this helps to narrow things right down.

NCrunch doesn't perform any kind of manipulation of referenced DLLs, and by setting your projects in compatibility mode, you've excluded any other kind of manipulation.

I strongly suspect this problem is being caused by the TypeMock profiler. This profiler integrates with the CLR at a low level and is able to manipulate any code loaded into the runtime. If there is a problem with the manipulation, the CLR will throw an error exactly like what you've described.

I suggest trying to uninstall TypeMock to see if this helps with the problem. Note that simply disabling the profiler may not be enough, as I believe it sets profiling at a fairly high level - but this is also worth a try as it may save you time with uninstalling/reinstalling.
graduss
#5 Posted : Friday, July 4, 2014 1:37:05 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/19/2014(UTC)
Posts: 5
Location: United Kingdom

Hi Remco,

I created the separate test project clean of TypeMock references within the main solution and add a dummy test to run in-memory RavenDb instance.
Then I add execute index call to the test body. The one that throws CLR exception. The test below

[Test]
public void Test()
{
using (var documentStore = new EmbeddableDocumentStore {RunInMemory = true}.Initialize())
{
documentStore.ExecuteIndex(new TestIndex());
}
}

And still the exception persist. But once I suspended TypeMock mocking the test is green under ncrunch.
This should be generic issue with the TypeMock. I presume everyone who's running raven db tests and have a type mock
should have the same issue.

Thanks
Remco
#6 Posted : Friday, July 4, 2014 10:41:52 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for checking this out. I think you're analysis is correct in that TypeMock's profiler is kicking up the issue when working with Raven DB.

Their support team is pretty responsive to these sorts of issues. Would you be interested in raising a support ticket with them?
jkells
#7 Posted : Monday, July 7, 2014 7:43:41 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/7/2014(UTC)
Posts: 1
Location: Australia

Hey,

I raised this with TypeMock about 4 months ago. It would be great if you could add your voice to my post so they know it's happening to others.

http://forums.typemock.c...pic.php?f=9&t=83379

Cheers
graduss
#8 Posted : Monday, July 7, 2014 8:33:26 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/19/2014(UTC)
Posts: 5
Location: United Kingdom

I will raise this issue with TypeMock.

Thanks
graduss
#9 Posted : Thursday, July 10, 2014 12:18:23 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/19/2014(UTC)
Posts: 5
Location: United Kingdom

I reported this issue to TypeMock. Here is a thread link http://forums.typemock.c...opic.php?f=9&t=91313
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.067 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download