1

This might be same problem as mentioned in the following link Publish web application with unsafe code

I have a wcf service with a block of Unsafe code. 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. 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#

Community
  • 1
  • 1
Karthik Dheeraj
  • 1,039
  • 1
  • 13
  • 25

1 Answers1

1

It seems when you publish it ignores the project setting of unsafe, so you need to manually open your .CSPROJ file and include:

  <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. Definately a bug.

Wolf5
  • 16,600
  • 12
  • 59
  • 58