Dan*_*lle 7 .net c# reflection .net-assembly .net-core
使用dotnet核心:.NET Core SDK版本:3.1.102
为什么以下返回 null
?
typeof(MyClassName).GetTypeInfo().Assembly.GetManifestResourceStream("MyFile.cs")
Run Code Online (Sandbox Code Playgroud)
我验证了该文件存在于解决方案中,并且在属性“嵌入式资源”中具有构建操作
您可以检查哪些资源名称可用:
string[] names = this.GetType().Assembly.GetManifestResourceNames();
Run Code Online (Sandbox Code Playgroud)
然后如果资源存在,请写入正确的资源名称