DependencyContext.Default is null under mono
See original GitHub issueSteps to reproduce
Program.cs
file
using System;
using Microsoft.Extensions.DependencyModel;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(DependencyContext.Default == null);
}
}
}
project.json
file:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.Extensions.DependencyModel": "1.0.0-rc2-final"
},
"frameworks": {
"net451": {
}
}
}
run dotnet run --framework net451
.
Expected behavior
console output as False
.
Actual behavior
console output as True
:
Project hwdotnet (.NETFramework,Version=v4.5.1) will be compiled because inputs were modified
Compiling hwdotnet for .NETFramework,Version=v4.5.1
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:03.1174645
True
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.0-preview1-002702)
Product Information:
Version: 1.0.0-preview1-002702
Commit Sha: 6cde21225e
Runtime Environment:
OS Name: ubuntu
OS Version: 14.04
OS Platform: Linux
RID: ubuntu.14.04-x64
mono:
Mono JIT compiler version 4.4.0 (Stable 4.4.0.148/fcf7a6d Thu Apr 28 14:51:58 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
DependencyContext.Default throws error in.net core Test ...
DependencyContext.Default uses Assembly.GetEntryAssembly() to probe for assemblies to load. For the running ASP.NET Core app under Kestrel, ...
Read more >DependencyContext.Default Property
Gets the dependency context for the current application.
Read more >C# (CSharp) DependencyContext Examples
Default, compileLibraries: new CompilationLibrary[] { } ... Assembly); if (dependencyContext != null) { foreach (var library in dependencyContext.
Read more >C# (CSharp) DependencyContext.GetDefaultAssemblyNames ...
<summary> /// Initializes a new instance of the <see cref="DependencyContextAssemblyProvider" /> class. /// </summary> /// <param name="context">The ...
Read more >Porting a .Net Framework Library to .Net Core
I have recently been involved with porting a couple of open source ... It includes just two sections, projects and sdk by default....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
‘preserveCompilationContext’ should be set to ‘true’ in ‘buildOptions’ to get ‘DependencyContext’ on full framework.
@pakrym @davidfowl
DependencyContext.Default
always returns null when executing from a .csproj of the “old stack” even though everything builds correctly.