且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 UWP 中使用 Roslyn 脚本

更新时间:2023-12-05 21:19:28

通过我这边的测试,我得到以下异常:

By testing on my side, I got the following exception:

System.NotSupportedException:AppX 不支持 Assembly.Load(byte[], ...)

System.NotSupportedException: Assembly.Load(byte[], ...) is not supported in AppX

和你的不一样.我使用了 Microsoft.CodeAnalysis.CSharp.Scripting 2.3.2代码>

Not the same with yours. I used Microsoft.CodeAnalysis.CSharp.Scripting 2.3.2

实际上,脚本 API 不能在通用 Windows 应用程序和 .NET Native 中使用,因为应用程序模型不支持加载在运行时生成的代码.详情请参考这篇文章的支持的平台"部分.因此,目前您应该无法使用 UWP 的脚本 API.

Actually scripting APIs can't be used within Universal Windows Applications and .NET Native since the application model doesn't support loading code generated at runtime. Details please reference the "Supported Platforms" section of this article. So that currently you should not be able to use the scripting API for UWP.