Rank: Member
Groups: Registered
Joined: 8/3/2012(UTC) Posts: 22
Thanks: 2 times Was thanked: 6 time(s) in 6 post(s)
|
I have an Xunit test that uses the classes from the Microsoft.AspNetCore.TestHost package to integration test an ASP.NET Core 2.0 project. The project uses a custom implementation of Microsoft.AspNetCore.DataProtection.Repositories.IXmlRepository that uses Dapper to retrieve data protection keys from a SQL Server database. Both the ASP.NET Core 2.0 project and its test project target .NET 4.6.1. If NCrunch tries to run it automatically when it is impacted by my changes it fails with the following message: "NCrunch was unable to retrieve a meaningful result from this test due to an unexpected error - was the execution process terminated?". If I then right-click on the test and select "Run selected test in a new task runner process", the test passes. If I right-click on the test and select "Debug selected test in a new task runner process", a SecurityException is thrown within seconds of Visual Studio attaching to the process. Intellitrace shows ADO.NET is attempting to query SQL Server as part of our custom IXmlRepository implementation. These are the exception details as copied to my clipboard by the unhandled exception modal: Code:
System.Security.SecurityException
HResult=0x8013150A
Message=Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source=mscorlib
StackTrace:
at System.StubHelpers.StubHelpers.DemandPermission(IntPtr pNMD)
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA& )
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA& )
at Microsoft.Win32.Win32Native.GetFileAttributesEx(String name, Int32 fileInfoLevel, WIN32_FILE_ATTRIBUTE_DATA& lpFileInformation)
And this is what is written to Visual Studio's Output window: Code:
System.Transactions Critical: 0 : <TraceRecord xmlns="(- BROKEN LINK -)" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>nCrunch.TestRunner.AppDomain_574b0f40679448ad9b02ded459716602</AppDomain><Exception><ExceptionType>System.Security.SecurityException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.</Message><StackTrace> at System.StubHelpers.StubHelpers.DemandPermission(IntPtr pNMD)
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA&amp; )
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA&amp; )
at Microsoft.Win32.Win32Native.GetFileAttributesEx(String name, Int32 fileInfoLevel, WIN32_FILE_ATTRIBUTE_DATA&amp; lpFileInformation)</StackTrace><ExceptionString>System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.StubHelpers.StubHelpers.DemandPermission(IntPtr pNMD)
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA&amp; )
at nCrunch.TestExecution.FileSystemAccessMonitor.(String , Int32 , WIN32_FILE_ATTRIBUTE_DATA&amp; )
at Microsoft.Win32.Win32Native.GetFileAttributesEx(String name, Int32 fileInfoLevel, WIN32_FILE_ATTRIBUTE_DATA&amp; lpFileInformation)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.SecurityPermission</ExceptionString></Exception></TraceRecord>
An unhandled exception of type 'System.Security.SecurityException' occurred in nCrunch.TestExecution.dll
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
|