简体   繁体   English

无法在Visual Studio 2013中发布带有不安全代码的WCF服务

[英]Unable to Publish WCF Service with Unsafe code in Visual Studio 2013

This might be same problem as mentioned in the following link Publish web application with unsafe code 这可能是与以下链接中发布的问题相同的问题,该链接使用不安全的代码发布Web应用程序

I have a wcf service with a block of Unsafe code. 我有一个带有不安全代码块的wcf服务。 I have Allowed Unsafe Code in My Project properties. 我的项目属性中允许使用不安全代码。 The Application is able build properly where as it is unable to publish the project. 该应用程序能够在无法发布项目的地方正确构建。 It Says Unsafe code may only appear if compiling with /unsafe error during the publishing the project. 说不安全代码仅在发布项目期间编译时出现/ unsafe错误时才出现 and finally says build failed. 最后说构建失败。

I feel its strange because it is able build the project successfully but failed in publishing. 我感到奇怪,因为它能够成功构建项目,但是发布失败。

I have tried the following help link but not worked for me. 我尝试了以下帮助链接,但对我不起作用。

how to add unsafe keyword in web based asp.net application c# 如何在基于Web的asp.net应用程序中添加不安全的关键字C#

It seems when you publish it ignores the project setting of unsafe, so you need to manually open your .CSPROJ file and include: 似乎在发布时会忽略不安全的项目设置,因此您需要手动打开.CSPROJ文件并包括:

  <PropertyGroup>
    ...
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

That solved it for me. 那为我解决了。

Googled this issue but could not find anything. 搜索了此问题,但找不到任何内容。 Checked the *.targets files for "unsafe" which led me to the "AllowUnsafeBlocks" tag. 检查* .targets文件中的“不安全”,这导致我进入“ AllowUnsafeBlocks”标记。 Definately a bug. 绝对是一个错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM