Why do I get the error "Unsafe code may only appear if compiling with /unsafe"?

Gold picture Gold · Jan 8, 2010 · Viewed 138.4k times · Source

Why do I get the following error?

Unsafe code may only appear if compiling with /unsafe"?

I work in C# and Visual Studio 2008 for programming on Windows CE.

Answer

Guffa picture Guffa · Jan 8, 2010

To use unsafe code blocks, the project has to be compiled with the /unsafe switch on.

Open the properties for the project, go to the Build tab and check the Allow unsafe code checkbox.