473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Unsafe code

Hi,

I have a question... I have some code which has an unsafe block in it.

In VS2008 (Framework 3.5), i go to the project property and check the
box that allows unsafe blocks. The code compiles fine.

On my build server though, things are not happy. The error seems to
be that /unsafe needs to be set as a command line option, even though
MSBuild is being used.

Shouldn't MSbuild be picking up the <AllowUnsafeBlocks /element in
the csproj file?

Thanks
Andy
Oct 15 '08 #1
5 6073

"Andy" wrote:
Hi,

I have a question... I have some code which has an unsafe block in it.

In VS2008 (Framework 3.5), i go to the project property and check the
box that allows unsafe blocks. The code compiles fine.

On my build server though, things are not happy. The error seems to
be that /unsafe needs to be set as a command line option, even though
MSBuild is being used.

Shouldn't MSbuild be picking up the <AllowUnsafeBlocks /element in
the csproj file?

Thanks
Andy
Hi Andy,

It should and it does for me. What kind of error do you get? If you add
AllowUnsafeBlocks=true to the command does it compile then?

--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 16 '08 #2
I get an error saying /unsafe has to be specified on the command
line...

If I add /:AllowUnsafeBlocks=true to the command line for msbuild, it
builds it. That's how I've worked around this, but because all my
builds use the same build command, they all now have that switch,
which isn't ideal to me.

On Oct 16, 2:19*am, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
It should and it does for me. *What kind of error do you get? *If youadd
AllowUnsafeBlocks=true to the command does it compile then?
Oct 17 '08 #3

"Andy" wrote:
I get an error saying /unsafe has to be specified on the command
line...

If I add /:AllowUnsafeBlocks=true to the command line for msbuild, it
builds it. That's how I've worked around this, but because all my
builds use the same build command, they all now have that switch,
which isn't ideal to me.

On Oct 16, 2:19 am, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
It should and it does for me. What kind of error do you get? If you add
AllowUnsafeBlocks=true to the command does it compile then?

Hi Andy,

Do you specify which platform and configuration msbuild should use on your
build machine? I believe MSBuild defaults to AnyCPU and Debug and if your
project files don't have the <AllowUnsafeBlock/node set in this
configuration it will complain about any unsafe blocks.

--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 17 '08 #4
Actually that raises a good point; I keep my configuration in Debug,
while my build server sets it to Release. I'll make sure to set this
for all configurations in the project file and see what happens.

On Oct 17, 12:12*pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
Do you specify which platform and configuration msbuild should use on your
build machine? I believe MSBuild defaults to AnyCPU and Debug and if your
project files don't have the <AllowUnsafeBlock/node set in this
configuration it will complain about any unsafe blocks.
Oct 20 '08 #5
HI,

Yes, that was it. I went to the Configuration settings and choose All
Configurations, and check Allow Unsafe code there, and it builds
correctly now.

Thanks for your help!
Andy

On Oct 17, 12:12*pm, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
Do you specify which platform and configuration msbuild should use on your
build machine? I believe MSBuild defaults to AnyCPU and Debug and if your
project files don't have the <AllowUnsafeBlock/node set in this
configuration it will complain about any unsafe blocks.
Oct 20 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Elidel | last post by:
Is the use of a COM object in a c# program considered 'unsafe' code ? Does the method that calls the COM object need the 'unsafe' keyword ? Is code that calls a COM object considered unmanaged?...
0
by: Wayne Gibson | last post by:
Hi, Firstly sorry for cross posting, but I didn't know which would be the best group to post too.. I was wondering if anybody could help me with a problem that I have. I have created a...
8
by: | last post by:
Wel, I am rebuilding the VC# 2002 project that I have deployment problems with the 2003 version, hoping this solves the problems, but now I encounter this wierd bug??? If I have the project, and...
4
by: Jon Milner | last post by:
How do I declare that my code is unsafe? Sorry the help files at my University have not been installed!
4
by: CodeTyro | last post by:
My native language being C++, I've got a few questions that a couple of hours of searching on msdn didn't answer. First, when using unsafe code and pointers, what is the C# equivalent to the C++...
4
by: Jerome | last post by:
Hi all, I *have* to use unsafe code, but I have a questions : it seems I can't use delete to free something like : int * myarray = new int. What should I do if I wanna create/delte/resize such...
3
by: rockdale | last post by:
Hi, all Could somebody tells me where can I set "Allow unsafe code" in visual studio 2005. I could not find any Project Properties|Configuration Properties in my website solution. Mine appl...
2
by: Daniel Knöpfel | last post by:
Hi all I need to adapt an Msbuild script to compile a visual studio 2005 solution (including several projects and a website). The application is written in C# and using .NET 2.0. Due to late...
0
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I have two piece of unsafe code. In the first one I'm getting the byte* pointer of a Bitmap data, and the second one in inside a loop that uses that byte* pointer to set the data in the Bitmap. ...
2
by: wizofaus | last post by:
Given the following code: public class Test { static unsafe void StringManip(string data) { fixed (char* ps = data) ps = '$'; }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.