Skip to content

DependencyContext.Default throws on .NET Native #3295

Closed
@bricelam

Description

@bricelam

Steps to reproduce

Install the Microsoft.Extensions.DependencyModel package into a UWP project and add a code like this:

var supported = DependencyContext.Default != null;

Run in Release mode (i.e. with .NET Native enabled)

Expected behavior

The supported variable should be false.

Actual behavior

System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Func`3.EndInvoke(IAsyncResult result) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.Reflection.Core\src\System\Reflection\Runtime\Modules\RuntimeModule.cs:line 75
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.GetDepsJsonPath(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.LoadAssemblyContext(Assembly assembly, IDependencyContextReader reader)
   at Microsoft.Extensions.DependencyModel.DependencyContextLoader.Load(Assembly assembly)
   at Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()
   at System.Func`1.InvokeOpenStaticThunk()
   at System.Func`1.Invoke()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Lazy.cs:line 330
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\shared\System\Lazy.cs:line 348

Environment data

Package version 2.1.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions