Unsafe Code Compilation error in .Net Core even after setting allowunsafe flag to true in project.json

白昼怎懂夜的黑 提交于 2019-12-09 08:23:30

问题


I am using some unsafe code in my .Net core App. For that i had made this change in the project.json file

"compilationOptions": { "allowUnsafe": true, }

Still this error comes error CS0227: Unsafe code may only appear if compiling with /unsafe

I had already gone through this already

Unsafe code won't compile on Visual Studio 2015

How to call unsafe code from ASP.NET xproj


回答1:


Change compilationOptions to buildOptions:

"buildOptions": {
    "allowUnsafe": true
}



回答2:


In the newer *.csproj files, this is now:

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

in any PropertyGroup.



来源:https://stackoverflow.com/questions/39256383/unsafe-code-compilation-error-in-net-core-even-after-setting-allowunsafe-flag-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!