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

Notification

Icon
Error

Embedded Resource DLLs cause System.OutOfMemoryException
Arlockff
#1 Posted : Friday, September 12, 2014 3:43:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 2
Location: United States of America

I have a C# Project that includes 2 .dll files with the following Properties settings:
Build Action : Embedded Resource
Copy to Output Directory : Do not copy

I also have two project references that respectively reference these 2 .dll files. Each of these references have their Properties settings for Copy Local set to False.

**These settings are required for me to have a single .exe file in my build's output directory**

The problem I am seeing is that as long as the 2 .dll files have their Build Action set to Embedded Resource, NCrunch fails to build this project due to a System.OutOfMemoryException even though the project builds just fine through Visual Studio (see following for full spit-out):

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Mono.Cecil.PE.ByteBuffer.Grow(Int32 desired)
at Mono.Cecil.PE.ByteBuffer.WriteBytes(Byte[] bytes)
at Mono.Cecil.MetadataBuilder.AddResources()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.<BuildMetadata>b__0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.#=q5vpF3zzm5zqKWCqcfbybS1u$DyuX6VxOlACprKPOhos=.#=qiXU_bNfvoheaf1Kj33xMBnSi6oPkLBSuauav99oaDfM=()
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.#=q7yp7R2vCg7OHrM_sd9tAMw==(Action #=qkWXG3M1rwpI6MlmUHfcmCA==)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly.Instrument(ComponentSourceLineMap sourceLineMap, IDictionary`2 instrumentationDirectivesByCodeFileId, IDictionary`2 codeFileIDsByFilePath, Boolean proxyProcessIsActive, Int32 componentId, IInstrumentationFilter[] instrumentationFilters)
at nCrunch.Compiler.RemoteBuildRunner.#=qgKRq1fUIr1IxXJQPqNrCdDnHIt2sr6IitqvDmQ34$FU=(ComponentBuildParameters #=qSQJL7L_EzBixm2aAhyr7pQ==, FilePath #=qOmmMHYYQpG_c7PD9b7zxTo$tlPrG1q1r5uLHobVtx_o=, BuildOutput #=qJ9z5KdrHTj3gG8xDkzDJpg==, DirectoryPath[] #=q8jp6VSMp9XO0CSWIyQa4EFaTpoE$OOwCDUtQgSXJHRQ=, FilePath[] #=qajJdvqLBN9egZtr61G5Ke8CCzie8cGDvhY6gfRfVdH2OyTQgx5OMzyo3KrStLz9q)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)

I am wondering if this is a known issue or if there are any settings I can changes to allow this project to build through NCrunch.

Thanks!
Remco
#2 Posted : Friday, September 12, 2014 9:59:13 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue. It's the first time I've seen this happen.

How large are the two DLL files? Do you notice any difference if one of these files is excluded from being embedded? Also, how much memory do you normally have available?

Is there any chance you can get me a code sample that can reproduce this?

Disabling the 'Instrument output assembly' setting for this project will allow you to work around this problem, but you'll lose all code coverage tracking across the project.
Arlockff
#3 Posted : Monday, September 15, 2014 3:42:15 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/12/2014(UTC)
Posts: 2
Location: United States of America

Thanks for the reply! The "Instrument output assembly" setting did the trick for me!

I cannot give sample code for this, but the two DLL files are both third party ones:
MahApps.Metro.dll (658 KB [673,792 bytes]) which can be acquired from a nuget package or from http://mahapps.com/
System.Windows.Interactivity.dll (39 KB [39,936 bytes]) which is needed for MahApps.Metro.dll

I found that NCrunch didn't like either of them as Embedded Resources. I am running on pretty good machine (12.0 GB RAM and a Xeon CPU on a Windows 7 64-Bit OS) and using Visual Studio 2013 with Update 3 (Version 12.0.30723.00).

Again, your suggestion fixed my problem, but hopefully this is enough to help you find out the underlying issue.

Thanks again,
James
Remco
#4 Posted : Monday, September 15, 2014 10:17:55 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Thanks James, I'll take a look and will see if I can reproduce the issue :)

Cheers,

Remco
Remco
#5 Posted : Friday, November 21, 2014 5:23:13 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi James,

Unfortunately I haven't had any luck in reproducing this issue.

I realise it's been a couple of months since you've reported it, so I'm not sure if this is still troubling you - but if it is, I'm wondering if setting the 'Build process CPU architecture' for this project to 'x64' in your NCrunch project settings makes any difference here? If you manage to put together a sample solution that can make this problem happen, I'd be really keen to get my hands on it. The samples I've attempted to build with the embedded files you've named for me don't seem to cause any memory issues in the build process.

Thanks!

Remco
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.059 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download