nunit - Unit testing with Roslyn.Services.Workspace results in a SecurityException while working at x86 target -
i'm working on set of constants project, , i'd use roslyn verify of them in source code level. achieve this, i'm loading entire solution using following snippet appdomain isfullytrusted == true , ishomogenous == true, i.e. remoting enabled x86 platform target:
// load workspace, i.e. solution visual studio var workspace = roslyn.services.workspace.loadsolution(solutionfile); test runners ncrunch , nunit x86 platform roslyn
but while using either ncrunch 1.45 or nunit 2.6.2 nunit-console-x86.exe platform configuration x86 test runners, i'm getting following system.security.securityexception:
system.security.securityexception : type system.runtime.remoting.objref , types derived (such system.runtime.remoting.objref) not permitted deserialized @ security level. server stack trace: @ system.runtime.serialization.formatterservices.checktypesecurity(type t, typefilterlevel securitylevel) @ system.runtime.serialization.formatters.binary.objectreader.checksecurity(parserecord pr) @ system.runtime.serialization.formatters.binary.objectreader.parseobject(parserecord pr) @ system.runtime.serialization.formatters.binary.objectreader.parse(parserecord pr) @ system.runtime.serialization.formatters.binary.__binaryparser.readobjectwithmaptyped(binaryobjectwithmaptyped record) @ system.runtime.serialization.formatters.binary.__binaryparser.readobjectwithmaptyped(binaryheaderenum binaryheaderenum) @ system.runtime.serialization.formatters.binary.__binaryparser.run() @ system.runtime.serialization.formatters.binary.objectreader.deserialize(headerhandler handler, __binaryparser serparser, boolean fcheck, boolean iscrossappdomain, imethodcallmessage methodcallmessage) @ system.runtime.serialization.formatters.binary.binaryformatter.deserialize(stream serializationstream, headerhandler handler, boolean fcheck, boolean iscrossappdomain, imethodcallmessage methodcallmessage) @ system.runtime.remoting.channels.corechannel.deserializebinaryrequestmessage(string objecturi, stream inputstream, boolean bstrictbinding, typefilterlevel securitylevel) @ system.runtime.remoting.channels.binaryserverformattersink.processmessage(iserverchannelsinkstack sinkstack, imessage requestmsg, itransportheaders requestheaders, stream requeststream, imessage& responsemsg, itransportheaders& responseheaders, stream& responsestream) exception rethrown @ [0]: @ system.runtime.remoting.proxies.realproxy.handlereturnmessage(imessage reqmsg, imessage retmsg) @ system.runtime.remoting.proxies.realproxy.privateinvoke(messagedata& msgdata, int32 type) @ roslyn.utilities.remoteservices.initialize(int32 clientprocessid) @ roslyn.utilities.remoteservices.startremoteservicesprocess() @ roslyn.utilities.remoteservices.get_instance() @ roslyn.utilities.remoteservices.createinstance[t]() @ roslyn.services.host.temporarystorageservicefactory.createservice(iworkspaceserviceprovider workspaceservices) @ roslyn.services.host.workspaceserviceproviderfactory.<>c__displayclass6.<onimportssatisfied>b__1(iworkspaceserviceprovider wsp) @ roslyn.services.host.workspaceserviceprovider.constructservice(type type) @ system.collections.concurrent.concurrentdictionary`2.getoradd(tkey key, func`2 valuefactory) @ roslyn.services.host.workspaceserviceprovider.getservice[tworkspaceservice]() @ roslyn.services.solutionservices..ctor(iworkspaceserviceprovider workspaceservices) @ roslyn.services.solution..ctor(solutionid id, string filepath, versionstamp version, versionstamp latestprojectversion, iworkspaceserviceprovider workspaceservices) @ roslyn.services.host.solutionfactoryservicefactory.solutionfactoryservice.createsolution(solutionid id) @ roslyn.services.host.trackingworkspace.createnewsolution(isolutionfactoryservice solutionfactory, solutionid id) @ roslyn.services.host.trackingworkspace..ctor(iworkspaceserviceprovider workspaceserviceprovider, boolean enablebackgroundcompilation, boolean enableinprogresssolutions) @ roslyn.services.host.hostworkspace..ctor(iworkspaceserviceprovider workspaceserviceprovider, boolean enablebackgroundcompilation, boolean enableinprogresssolutions, boolean enablefiletracking) @ roslyn.services.host.loadedworkspace..ctor(iworkspaceserviceprovider workspaceserviceprovider, idictionary`2 globalproperties, boolean enablebackgroundcompilation, boolean enablefiletracking) @ roslyn.services.host.loadedworkspace.loadsolution(string solutionfilename, string configuration, string platform, boolean enablefiletracking) @ roslyn.services.workspace.loadsolution(string solutionfilename, string configuration, string platform, boolean enablefiletracking) there a discussion on ncrunch forum, but have tried following options without success:
add[assembly: allowpartiallytrustedcallers]assemblyinfo.csadd[assembly: securityrules(securityruleset.level1)]assemblyinfo.csadd<netfx40_legacysecuritypolicy enabled="true" />app.configrun vs2012 administratordecorate both unittests , implementation[securitysafecritical]update: create newappdomain, providepermissionstate.unrestricted,securitypermissionflag.allflags,dataprotectionpermissionflags.allflagsadd host evidence:securityzone.mycomputer,system.security.policy.hash,system.security.policy.strongnameadd assemblies (both mine , roslyn ctp)fulltrustassemblieswhile creating ofappdomain
update #2
this exception happens while i'm running test under x86 configuration, after had switched x64 platform configuration, seems work fine
question
are there other attributes or configuration changes app.config or appdomain enable deserialization in .net framework remoting system.runtime.remoting.objref while running under x86 configuration?
temporary solution
switch x64 build configuration unittest project(s)
source code
- whole source code available @ github: reproduce error run following unittest using ncrunch
introspectiontests.introspection_searchforcomplexitygt10_approvedlist - discussion @ ncrunch forum
additional information
also notice...
- a lot of instances of
roslyn.services.dllhang in background, after tests had been completed. - lack of host evidences ncrunch:
system.security.policy.hash,system.security.policy.strongnametest runner assembly name - resharper msil (should x64 inside) , nunit 2.6.2
nunit-console.exetest runner working fine, looks roslyn configuration/remoting/security configuration issue.
it looks ncrunch executing tests in partial trust, whereas resharper running them in full trust.
roslyn has not been tested in partial trust scenarios. there accesses apis require full trust.
i haven't used ncrunch, maybe there way configure run tests in full trust?
Comments
Post a Comment