0

i used unsafe inside class but its not working. It gives error :

Unsafe code may only appear if compiling with /unsafe.

May i know how to use unsafe keyword in asp.net(visual studio 2008) page.

Asp.net c#

Thank you.

3 Answers 3

1

Try adding /unsafe to the conditional compilation symbols under the Build tab in the project properties.

Sign up to request clarification or add additional context in comments.

Comments

0

If you use "unsafe" keyword within your project you need to include /unsafe upon compilation. This tells the JIT compiler to compile the unsafe code and allow it to run.

Comments

0

In Visual Studio (2005 - 2010), on the Project Properties page, in the Build tab, there's a checkbox that says "Allow unsafe code". You need to check this, and then re-build your project.

screenshot from Visual Studio 2010

5 Comments

under build tag there is no checkbox for "Allow unsafe code".
I guess it depends on the version of Visual Studio. There's definitely one in VS 2010!
i am using VS 2008 so whats the solution?
I just looked at VS2008 and I could see the check box there. Are you sure you don't see that. Goto Properties, Select Build Tab, under General, you will see two check boxes, one is Allow Unsafe code and other is Optimize Code
@user707294 - see this MSDN page - msdn.microsoft.com/en-us/library/ct597kb0(v=VS.90).aspx - the checkbox should be there on VS 2008 (and also VS 2005)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.