最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - GetFields returning empty on .NET native - Stack Overflow

programmeradmin4浏览0评论

I have a C# application that uses reflection to enumerate an object's fields:

foreach (FieldInfo field in t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)

This works just fine, except when I try to produce a single .exe file with ahead of time compilation, in which case no fields are returned.

I understand that .NET native can strip the metadata required for reflection to work, but haven't been able to find a straight answer to what to do to fix this issue.

So how can I get the fields to appear when using .NET native? I am using Visual Studio 2022.

发布评论

评论列表(0)

  1. 暂无评论