Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[2.x] Warnings when `PublishAot` is enabled.

Đang mở
#2,633 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend, devtools

Hướng nghiên cứu

Start in Silk.NET.Core.Loader.DefaultPathResolver, where the warnings identify Assembly.Location, Assembly.CodeBase, and DependencyContext.Default usage. Reproduce with a small .NET 10 project using PublishAot=true and Vk.GetApi(), then trace the resolver paths that trigger the warnings. Done means AOT publishing no longer emits the reported warnings while native library loading continues to work.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Summary

Silk.NET library loader generates warnings when AoT is enabled. Everything works at runtime with AOT, but warnings are reported and cannot be easily supressed.

Steps to reproduce

  • Platform: Any (tested on Windows 11)
  • Dotnet: v10.0.x
  1. Create a new dotnet project with <PublishAot>true</PublishAot>
  2. Add one single line: using var vk = Vk.GetApi();. It fails with any Foo.GetApi() call, not only with Vulkan.
  3. You get the following warnings:
jhmci@CIBERMAN-PC MINGW64 /c/repos/open-source/silk-aot-repro
$ dotnet publish -c Release -r win-x64 -p:PublishAot=true
Restore complete (0.5s)
  SilkAotRepro net10.0 win-x64 succeeded with 6 warning(s) (9.0s) → bin\Release\net10.0\win-x64\publish\
    ILC : warning IL3000: Silk.NET.Core.Loader.DefaultPathResolver.<>c.<.cctor>b__24_3(String): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
    ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.<>c.<.cctor>b__24_3(String): Using member 'System.Reflection.Assembly.CodeBase.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. This member throws an exception for assemblies embedded in a single-file app.
    ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetFromDeps(String,String&,String&): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.Default.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
    ILC : warning IL3000: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetFromDeps(String,String&,String&): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
    ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetInRuntimesFolder(String,String,String&): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.Default.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
    ILC : warning IL3002: Microsoft.Extensions.DependencyModel.DependencyContext..cctor(): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.

Build succeeded with 6 warning(s) in 10.4s

Comments

Add any other context about the problem here.

If you know how to fix this issue, please submit a pull request instead!

Ngôn ngữ chính
C#
Star
5.3k
Fork
484
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/Silk.NET

Tất cả issue của dotnet/Silk.NET

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.