This is the error message you get, when you build a project with some bit of unsafe code in it.

Simply you need to "Alt + Enter" on the project to see the properties and tick on "Allow unsafe code" on build tab. Then it compiles lovely in visual studio.

However, I came across the error message again in the build. with MSBuiild, I got the message. It's still ticked on the project's property page. What's wrong? ...

The culprit was build type. In VS, you usually set the build type to DEBUG. so the Allow unsafe code option is turned on against debug, not release. So, open the project file in a simple text editor. I used Sublime text 2. Make sure the option exists in both debug and release.

[sourcecode language="xml"]
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\Penge\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
[/sourcecode]


Andrew Chaa

another day, another PR