aspnet / dnx

OBSOLETE - see readme
Other
963 stars 224 forks source link

MethodAccessException in unit test discovery for project k #467

Closed anandparanjape closed 10 years ago

anandparanjape commented 10 years ago

I am hitting below exception while running unit tests for project k when I set K10 as active target framework.

System.MethodAccessException: Attempt by method 'Xunit.KRunner.Program..ctor(System.IServiceProvider, Microsoft.Framework.Runtime.IApplicationEnvironment, Microsoft.Framework.Runtime.IFileMonitor)' 

------ Discover test started ------
Discovering tests in 'C:\Mvc-dev\Mvc-dev\samples\MvcSample.Web\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc.Common\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc.Core\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc.ModelBinding\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc.Razor.Host\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc.Razor\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\src\Microsoft.AspNet.Mvc\project.json'
Discovering tests in 'C:\Mvc-dev\Mvc-dev\test\Microsoft.AspNet.Mvc.Test\project.json'
Error discovering tests in 'C:\Mvc-dev\Mvc-dev\test\Microsoft.AspNet.Mvc.Test\project.json'
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MethodAccessException: Attempt by method 'Xunit.KRunner.Program..ctor(System.IServiceProvider, Microsoft.Framework.Runtime.IApplicationEnvironment, Microsoft.Framework.Runtime.IFileMonitor)' to access method 'System.Collections.Concurrent.ConcurrentDictionary`2<System.__Canon,System.__Canon>..ctor()' failed.
   at Xunit.KRunner.Program..ctor(IServiceProvider services, IApplicationEnvironment environment, IFileMonitor fileMonitor) in C:\BuildAgent\work\7099317a75e1c33b\src\Xunit.KRunner\Program.cs:line 23
   --- End of inner exception stack trace ---
anandparanjape commented 10 years ago

Now I am getting error "An exception occurred while test discoverer 'KUnitTestDiscoverer' was loading tests. Exception: The operation is not allowed on non-connected sockets."

davidfowl commented 10 years ago

@anandjp where do you see that error? Is it only for full CoreCLR?

anandparanjape commented 10 years ago

@davidfowl Discovery is now working fine for desktop and coreCLR with latest fixes from Vijay...

Below error shows up on CoreCLR while running unit test tests.

------ Run test started ------ Running tests in 'C:\Users\anandjp\Documents\Visual Studio 14\Projects\WebApplication4\test\WebApplication4.Tests\project.json' Error running tests in 'C:\Users\anandjp\Documents\Visual Studio 14\Projects\WebApplication4\test\WebApplication4.Tests\project.json' System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: System.MethodAccessException: Attempt by security transparent method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Object[])' to access security critical method 'Newtonsoft.Json.Utilities.CollectionWrapper`1..ctor(System.Collections.Generic.ICollection`1)' failed. at lambda_method(Closure , Object[] ) at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList(JsonReader reader, JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject[T]() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessMessage() at Microsoft.Framework.DesignTimeHost.ApplicationContext.DoProcessLoop() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessLoop(Object state) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.VisualStudio.Web.KUnit.TestAdapter.Execution.HostExtensions.ExecuteTests(IHost host, IFrameworkHandle framework, IEnumerable`1 tests, KUnitTestConfiguration testConfiguration) at Microsoft.VisualStudio.Web.KUnit.TestAdapter.KUnitTestExecutor.RunTests(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle) ---> (Inner Exception #0) System.InvalidOperationException: System.MethodAccessException: Attempt by security transparent method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Object[])' to access security critical method 'Newtonsoft.Json.Utilities.CollectionWrapper`1..ctor(System.Collections.Generic.ICollection`1)' failed. at lambda_method(Closure , Object[] ) at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList(JsonReader reader, JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject[T]() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessMessage() at Microsoft.Framework.DesignTimeHost.ApplicationContext.DoProcessLoop() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessLoop(Object state)<--- An exception occurred while invoking executor 'executor://kunittestexecutor/v1': One or more errors occurred. System.MethodAccessException: Attempt by security transparent method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Object[])' to access security critical method 'Newtonsoft.Json.Utilities.CollectionWrapper`1..ctor(System.Collections.Generic.ICollection`1)' failed. at lambda_method(Closure , Object[] ) at Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(Object list) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewList(JsonReader reader, JsonArrayContract contract, Boolean& createdFromNonDefaultCreator) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer) at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType) at Newtonsoft.Json.Linq.JToken.ToObject[T]() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessMessage() at Microsoft.Framework.DesignTimeHost.ApplicationContext.DoProcessLoop() at Microsoft.Framework.DesignTimeHost.ApplicationContext.ProcessLoop(Object state)

davidfowl commented 10 years ago

@anandjp move all testing issues to the Testing repository. This is still a problem however

anandparanjape commented 10 years ago

thanks. Opened new issue#45 in testing repository