如何调用从ASP.NET xproj不安全的代码 [英] How to call unsafe code from ASP.NET xproj

查看:165
本文介绍了如何调用从ASP.NET xproj不安全的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我创建了一个类库在Visual Studio 2015年新的类库(包)模板,显然,它使用了花哨的新项目格式,在ASP.NET xproj ,用于建立包。虽然这由我很好,我怎么叫从库不安全的代码?我看着项目>属性>生成,其中选项切换不安全的代码是应该的,但我得到的是这样的:

I created a class library today with the new Class Library (Package) templates in Visual Studio 2015. Apparently it uses a fancy new project format, the ASP.NET xproj, for building the package. While that's fine by me, how do I call unsafe code from the library? I looked into Project > Properties > Build, where the option to toggle unsafe code should be, but all I got was this:

<一个HREF =http://i.stack.imgur.com/xgutc.png>

所以,是的,没有这样的运气。我甚至尝试粘贴< AllowUnsafeBlocks>真< / AllowUnsafeBlocks>中。手动进.xproj文件,但编译器仍然抱怨

So yeah, no such luck. I even tried pasting "<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" manually into the .xproj file, but the compiler still complains.

是否有可能实现这一点没有为不安全的方法创建另一个非xproj组装?

Is it possible to enable this without creating another non-xproj assembly for the unsafe methods?

推荐答案

的ASP.NET 5工具不记录几乎不够好,但谷歌淘半小时后,我整个的解决方案来。

The ASP.NET 5 tools are not documented nearly well enough, but after scouring Google for half an hour I came across the solution.

在您project.json文件,添加此行:

In your project.json file, add this line:

{
    "buildOptions": { "allowUnsafe": true }
}

来源。

这篇关于如何调用从ASP.NET xproj不安全的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆