471,339 Members | 1,284 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How do I determine the build mode using reflection?

My company is setting up a deployment process for implementing .NET Windows
applications. One of the standards we want the process to enforce is
verifying that the assembly is built in release mode. Is there a way to
check an assembly to determine if it was built in release mode? The
deployment application will not have access to source code, just the compiled
assembly, so I am assuming I will need to use reflection. However, I have
not found anything in the System.Reflection namespace that provides the build
mode. Any ideas?

Jul 25 '05 #1
6 1909
Jan
The pre-compiler definitions are are only available at compile time.

Anyway, (using default project settings) there is no difference between
a Release and a Debug build since the Symbol Store information is
stored in a separate .pdb file.

So why exactly have you choosen to enfore this policy?

Jan

Jul 25 '05 #2
"Jan" <ja***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
The pre-compiler definitions are are only available at compile time.

Anyway, (using default project settings) there is no difference between
a Release and a Debug build since the Symbol Store information is
stored in a separate .pdb file.


With the default settings, Release is optimized and Debug isn't.

Jul 25 '05 #3
"Brad" <br********@newsgroup.nospam> wrote in message
news:E3**********************************@microsof t.com...
My company is setting up a deployment process for implementing .NET Windows applications. One of the standards we want the process to enforce is
verifying that the assembly is built in release mode. Is there a way to
check an assembly to determine if it was built in release mode? The
deployment application will not have access to source code, just the compiled assembly, so I am assuming I will need to use reflection. However, I have
not found anything in the System.Reflection namespace that provides the build mode. Any ideas?


Hi Brad, I know this is possible because I had to do it 2 or 3 years ago. My
memory is getting progressively worse these days, but I'm pretty sure I used
the DebuggableAttribute. Have a look at it, it allows you to check whether
the code is JIT optimised or not. I'm pretty sure that this attribute is
added to an assembly automagically on a debug build. So a wee bit of
reflection should give you the information you need.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
Jul 26 '05 #4
Jan
But do you know what optimizations those are? I've profiled debug and
release on a couple of applications and there's been no performance
gain but realease was smaller. So the optimatization is probably space
not speed.

Jul 26 '05 #5
Jan
You're totally right [assembly: Debuggable(true, true)] is set if it's
a debug build.
You learn something new everyday!

Jan

Jul 26 '05 #6
"Jan" <ja***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
But do you know what optimizations those are? I've profiled debug and
release on a couple of applications and there's been no performance
gain but realease was smaller. So the optimatization is probably space
not speed.


You probably weren't doing anything intensive enough for it to matter. Some
more complex C# apps I've worked on experience 500% performance increases
when run in release. Admittedly some of this is undoubtedly due to
configuration dependent execution.

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
Jul 26 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Chris Becker | last post: by
2 posts views Thread by Stu | last post: by
3 posts views Thread by nautonnier | last post: by
12 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by
1 post views Thread by SetonSoftware | last post: by

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.