Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Error building native console app on OS X #1226

Closed

Description

@mikebluestein

small program that calls a rest service using http client and parses the results with newtonsoft json.

works ok without native.

Here's the error I get when building with -n option:

Input Assembly: /Users/mbluestein/ConsoleClientDotnetCore/bin/Debug/dnxcore50/ConsoleClientDotnetCore.dll
Error: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Internal.TypeSystem.Ecma.EcmaType.GetFinalizer()
   at Internal.TypeSystem.MetadataType.get_HasFinalizer()
   at ILCompiler.JitHelper.GetNewObjectHelperForType(TypeDesc type)
   at ILCompiler.DependencyAnalysis.ReadyToRunHelperNode.EmitCode(NodeFactory factory, X64Emitter& encoder, Boolean relocsOnly)
   at ILCompiler.DependencyAnalysis.AssemblyStubNode.GetData(NodeFactory factory, Boolean relocsOnly)
   at ILCompiler.DependencyAnalysis.ObjectNode.GetStaticDependencies(NodeFactory context)
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1 node)
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack()
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes()
   at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.get_MarkedNodeList()
   at ILCompiler.Compilation.CompileSingleFile()
   at ILCompiler.Program.Run(String[] args)
   at ILCompiler.Program.Main(String[] args)

Activity

  1. MichalStrehovsky commented on May 2, 2016

    @MichalStrehovsky
    Member

    You'll typically see this crashing here if the program (or one of the assemblies it refers to) ended up referencing mscorlib and System.Object from mscorlib. The CoreRT compiler doesn't have compatibility shims that would make this work and we didn't invest in diagnostics for invalid inputs yet.

    All assemblies fed to ILC need to be compiled against the .NET Core contracts (and use System.Object from the System.Runtime contract).

  2. mikebluestein commented on May 2, 2016

    @mikebluestein
    Author

    I tried removing newtonsoft.json, thinking that may be the culprit, but to no avail. I'm only taking System.Net.Http as a dependency and get the same error. Here's my project.json:

    {
        "version": "1.0.0-*",
        "compilationOptions": {
            "emitEntryPoint": true
        },
    
        "dependencies": {
            "NETStandard.Library": "1.0.0-rc2-23811",
            "System.Runtime": "4.1.0-rc2-23811"
        },
    
        "frameworks": {
            "dnxcore50": {
                "dependencies": {
                    "System.Net.Http": "4.0.1-rc2-23811"
                }
            }
        }
    }
    
  3. MichalStrehovsky commented on May 2, 2016

    @MichalStrehovsky
    Member

    The biggest problem is the dnxcore50 moniker. That means CoreCLR and it's quite likely it ends up using assemblies that are written for CoreCLR.

    We're getting away with it in our testing because we only use a limited subset that is "known good" and provide overrides in the Microsoft.DotNet.AppDep package for everything else. The framework team is not making bigger investments in this area yet and is waiting until the compiler gets more mature. We're getting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions