Skip to content

NativeAOT when building shared library #71063

@rodrigovaras

Description

@rodrigovaras

Description

Attempting to create a shared library using the NativeAOT tools on my managed assembly entry point.
I tried the NativeLibrary and succeeded but not my project.

Reproduction Steps

Create a .NET project that has several dependencies. Attempt to run:
dotnet publish /p:NativeLib=Shared /p:SelfContained=true -r win-x64 -c Release <Myproject.csproj>

Expected behavior

Native library being created for the Windows platform

Actual behavior

EXEC : error : Failed to load type 'Void ()' from assembly '?' [D:\mr\mixedreality.eu.proto\client\sdk.net\src\Hololen
s\Hololens.Runtime.Native\Hololens.Runtime.Native.csproj]
Internal.TypeSystem.TypeSystemException+TypeLoadException: Failed to load type 'Void ()
' from assembly '?'
at Internal.TypeSystem.ThrowHelper.ThrowTypeLoadException(ExceptionStringID id, String typeName, String assemblyNa
me) in //src/coreclr/tools/Common/TypeSystem/Common/ThrowHelper.cs:line 17
at ILCompiler.DependencyAnalysis.EETypeNode..ctor(NodeFactory factory, TypeDesc type) in /
/src/coreclr/tools/aot/
ILCompiler.Compiler/Compiler/DependencyAnalysis/EETypeNode.cs:line 81
at ILCompiler.DependencyAnalysis.NodeFactory.CreateNecessaryTypeNode(TypeDesc type) in //src/coreclr/tools/aot/IL
Compiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs:line 508
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at ILCompiler.DependencyAnalysis.ReflectableFieldNode.GetStaticDependencies(NodeFactory factory) in /
/src/coreclr
/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectableFieldNode.cs:line 89
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.GetStaticDependenciesImpl(DependencyNodeCore1 node
) in //src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 181
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.GetStaticDependencies(DependencyNodeCore1 node) in
/
/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 221
at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.ProcessMarkStack() in /_/src/coreclr/tools/aot/ILCo mpiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 256 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.ComputeMarkedNodes() in //src/coreclr/tools/aot/IL
Compiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 307
at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /
/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILSc
anner.cs:line 140
at ILCompiler.Program.Run(String[] args) in //src/coreclr/tools/aot/ILCompiler/Program.cs:line 833
at ILCompiler.Program.Main(String[] args) in /
/src/coreclr/tools/aot/ILCompiler/Program.cs:line 1090
C:\Users\rodrigov.nuget\packages\microsoft.dotnet.ilcompiler\7.0.0-preview.6.22321.1\build\Microsoft.NETCore.Native.ta
rgets(270,5): error MSB3073: The command ""C:\Users\rodrigov.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompile
r\7.0.0-preview.6.22321.1\tools\ilc" @"D:\mr\mixedreality.eu.proto\client\sdk.net\bin\obj\Hololens.Runtime.Native\Rele
ase\net6.0-windows10.0.19041.0\win-x64\native\MixedReality.EU.HoloLens.Runtime.Native.ilc.rsp"" exited with code 1. [D:
\mr\mixedreality.eu.proto\client\sdk.net\src\Hololens\Hololens.Runtime.Native\Hololens.Runtime.Native.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

.NET -> 6.0.300
Architecture : win-x64

Other information

No response

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