c# - Unable to load assembly when referencing BindingFlags type in Windows 10 Universal Windows library -


when running unit tests, calling method in portable runtime library dll references "system.reflection.typeextensions" generates filenotfound exception, searching "system.reflection.typeextensions". error not occur when same code executed in windows 10 universal app.

the project c# portable runtime library, configured support .net framework 4.6 , windows universal 10.0. test project configured use .net framework 4.6.

whenever attempt call method uses system.reflection.bindingflags type, following exception. exception occurs call starts (presumably while jit-ing function).

test method sfx.test.signalexpressiontest.testaddexpressions threw exception:  system.io.filenotfoundexception: not load file or assembly 'system.reflection.typeextensions, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a' or 1 of dependencies. system cannot find file specified.=== pre-bind state information === log: displayname = system.reflection.typeextensions, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a  (fully-specified) 

adding packages right thing do. here why see behavior:

  1. bindingflags [1] exposed in system.reflection.typeextensions.
  2. when compile .net core class library, compiler records type reference system.reflection.typeextensions!system.reflection.bindingflags.
  3. when consume class library .net framework application, need add reference system.reflection.typeextensions otherwise compiler cannot resolve type. same true unit testing project has deploy code in order run.
  4. at runtime, clr resolve type, find type forward points mscorlib!system.reflection.bindingflags , happily run code.

as general rule of thumb: .net core designed deploy framework in app-local fashion, in other words, when application deployed folder, closure of dependencies need deployed too. although unit test projects conceptually class libraries, same applies because executed applications.

of course, don't expect folks manually tweak references , hunt down dependencies. see pre-release bits not pieces in our tooling experiences right thing.

two questions side:

  1. which unit testing framework use? assume it's mstest (microsoft.visualstudio.testtools.unittesting), opposed xunit or nunit?

  2. which runner using? assume it's built-in visual studio test explorer (as opposed resharper or testdriven.net)?


[1] because based on customer feedback decided move system.reflection, apis take bindingflags.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -