Unsafe code won't compile on Visual Studio 2015
Asked Answered
M

3

11

I'm trying to compile a program on the new DNX4.6 core, but it won't compile due to:

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

This is my code:

    [CompilerGenerated]
    public unsafe class GrayscaleQuantizer : PaletteQuantizer
    {
I've looked online, and I can't get any source with the same problem as I have. I can't tick the 'Allow Unsafe Code' at the Build tab of the Project Properties, because there is no option to do so...

Does anyone know a solution?

Marou answered 8/7, 2015 at 14:9 Comment(0)
M
13

You need to set "allowUnsafe": true in the build options in project.json.

Mode answered 8/7, 2015 at 14:13 Comment(0)
T
3

I wasn't smart enough to be able to figure it out with the help above. I did find that if you go to the solution explorer window and right click on properties, the one just above references, there will be an option to open. Click that one and then click on Build on the left. Allow unsafe code is on about the fifth line.

Thulium answered 3/5, 2016 at 9:56 Comment(0)
K
0

Thanks for your help 5 years into the future. I couldn't find it either. I didn't know you needed to do your steps above for the "Allow unsafe code" check box to appear in the "Build" section on the left. It shows up just below "Prefer 32-bit" check box, after you follow the above instructions.

Kaikaia answered 10/9, 2021 at 17:11 Comment(2)
Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. - From ReviewSnooker
I do not see how this answers the question at the top of this page, but it should. Please edit according to How to Answer or delete the answer. Otherwise it risks being flagged as "not an answer" and being deleted.Fagan

© 2022 - 2024 — McMap. All rights reserved.