blah blah blah is here! blah blah » Close

up0down
link

I have a method that must use unsafe code to run.
private unsafe void myMethod()
when I compile (in Windows Application) there's an error say that "Unsafe code may only appear if compiling with /unsafe"
How can I fix the error?
Thank you and regards,

last answered 2 years ago

1 answers

up0down
link

It means the compiler needs the flag that says "unsafe code can be used here".
There should be an option within your projects properties to toggle this flag (though I'm not exactly sure where it is at off the top of my head).

up0down
link

you will find an option in the project properties under build (as i remember) called (enable unsafe blocks) or something like that make this option true and rebuild

up0down
link

Hi
If you are using VS.NET, do the following:
Step 1: Go to Solution Explorer
Step 2: Right Click Project and Select Properties
Step3: Choose Configuration Properties -> Build
Step 4: Set Allow unsafe Code blocks is true
Step5: Click OK.
Now you can compile the program.
_Vipins

up0down
link

Thank you very much, it worked.

up0down
link

Thank you for your help

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback