Problems to activate Allow Unsafe. I can not run unsafe

0

I'm making a website published in hostlocal in C # and VisualStudio 2015. I need to set the AllowUnsafeBlocks option, for a class that uses pointers, but I can not. I'm sure it's silly, but I do not see it and I'm going crazy.

When I open the project properties page, in the Compile section, I do not get the option as it should to allow the unsafe code. I only get this:

In the solution explorer, it does not appear either. I do not understand it!

The other option is to add the following lines in the .csproj file:

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

The problem is that I do not have any .csproj file since it is a web created directly against the IIS. Yes there is a .sln file

The configuration files I have are: website.publishproj, web.config, vwd.webinfo, compilerconfig.json

Any suggestions? How can I configure VS 2015 to see it, or how to add a code in some configuration file?

    
asked by JoseDEV 02.11.2018 в 23:25
source

1 answer

1

The option does not appear because as I see you have a web site and not a web project

Converting to Web Site Project to a Web Application Project

otherwise you should see the option

Compiling Unsafe Code in Visual Studio

Now at the level of web.config you could validate this configuration section

<system.codedom>
    <compilers>
        <compiler 
            language="c#;cs;csharp" 
            extension=".cs" 
            compilerOptions="/unsafe"
            type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    </compilers>
</system.codedom>

validate that you have compilerOptions="/unsafe"

    
answered by 03.11.2018 в 00:57