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

Notification

Icon
Error

System.TypeInitializationException
ivoloshin
#1 Posted : Monday, September 10, 2012 2:52:52 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/18/2012(UTC)
Posts: 6
Location: Jacksonville, FL

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
I am using VS 2012 with NCrunch. I'm running NUNit tests using Resharper, VS and NCrunch. The problem I have is in an older log4net library that throws System.TypeInitializationException when creating a logger.

I added the following to App.config fix this:

<runtime>
<NetFx40_LegacySecurityPolicy enabled="true" />
</runtime>


This has made it so that the application runs without the error, and the unit tests pass in Resharper test runner as well as MS Test runner. I still have this error in NCrunch, however.

I tried making the following modification to files:

nCrunch.build.4.0.config
nCrunch.TaskRunner40.x64.exe.config
nCrunch.TaskRunner40.x86.exe.config

<runtime>
<NetFx40_LegacySecurityPolicy enabled="true" />
<legacyUnhandledExceptionPolicy enabled="0" />
</runtime>

This did not help.

Thanks,
Ilya
Remco
#2 Posted : Monday, September 10, 2012 10:22:19 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1258 time(s) in 1171 post(s)
Hi Ilya,

Depending upon its configuration, NCrunch will usually run your tests inside a hosted environment that doesn't consider the .config files. However, you can easily change this.

Under your global NCrunch configuration, you'll find an option called 'Use hosted task runner'. Set this to FALSE, and your modifications to the nCrunch.TaskRunner*.config files should start working.


Cheers,

Remco
1 user thanked Remco for this useful post.
ivoloshin on 9/11/2012(UTC)
ivoloshin
#3 Posted : Tuesday, September 11, 2012 12:31:46 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/18/2012(UTC)
Posts: 6
Location: Jacksonville, FL

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Thanks for the reply!

This did not seem to help my problem, however.

I'll try to set up a sample project to demonstrate the problem.

Thanks,
Ilya
Remco
#4 Posted : Tuesday, September 11, 2012 9:10:13 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1258 time(s) in 1171 post(s)
Make sure you reset the engine after applying this setting. If it takes effect, you should see the NCrunch task runners as showing up under the names 'nCrunch.TaskRunner40.x86.exe', etc.

I'll message you with an email address if you'd like to send a sample project. NCrunch has seen limited testing around CAS and there are a number of known issues at the moment, so it would probably be good to solve this one at the same time!


Cheers,

Remco
1 user thanked Remco for this useful post.
ivoloshin on 9/12/2012(UTC)
ivoloshin
#5 Posted : Wednesday, September 12, 2012 2:00:30 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/18/2012(UTC)
Posts: 6
Location: Jacksonville, FL

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Remco,

I was not able to reproduce the exception in a standalone example and the full solution is too large to send anyway. I did, however, find a way to make our library work correctly by adding the following to AssemblyInfo.cs:

[assembly: SecurityRules(SecurityRuleSet.Level1)]

Not an ideal solution, but it'll work for us for now.

Thanks!
Ilya
Remco
#6 Posted : Wednesday, September 12, 2012 8:48:49 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 932 times
Was thanked: 1258 time(s) in 1171 post(s)
Thanks, I'll have a play with it and see what I can find.
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.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download