Unsafe code may only appear if compiling with /unsafe error

By Mahesh Chand Blogs | Visual Studio 2010 Jul 26, 2012
You get Unsafe code may only appear if compiling with /unsafe error when trying to debug or build unsafe code in Visual Studio.
You get Unsafe code may only appear if compiling with /unsafe error when trying to debug or build unsafe code in Visual Studio. 

To fix this error, you need to set your project setting to build and/or debug unsafe code. 

To set unsafe build, go to your project in Solution Explorer.

Right click on Project Name and select Properties. 

Go to Build tab and select "Allow unsafe code" 

unsafe1.jpg


To debug unsafe code, go to Debug tab and select "Enable unmanaged code debugging"

unsafe2.jpg
COMMENT USING