4
I’m trying to use the directive #if
for a given method to be executed only after publication (in release mode).
The code is something like
#if !DEBUG
AlgumMetodo();
#endif
I’ve also tried to add the ConditionalAttribute
in the signature of the method
[Conditional("RELEASE")]
private void AlgumMetodo() { ... }
The problem is that of the two forms the method never is executed, no matter if it is in mode release or debug.
I already checked the properties of the project, in the tab build. In configuration release the checkbox define DEBUG constant
is unchecked and in configuration debug he is marked.
Is there any other configuration I can verify or something I’m doing wrong?
Try putting a
#define RELEASE
at the beginning of this code to see if anything changes, at least we’ll know better where the problem is. I’ve never used this, but I don’t think it’s used like this. I think if it’s to be used in release, then leave normal, only block what should only be used in debug mode.– Maniero
I need just the opposite. I need the method not run if it is in debug. Anyway I managed to resolve by setting
RELEASE
in the build settings of the project.– Jéf Bueno
It’s a little weird that, I think you’re conceptualizing wrong. I don’t think resources were created to do this. Still you need to do tests to find out where the problem is, as I said.
– Maniero
You are
Publicando
your app or picking up the contents of bin folder? remember that the contents of bin folder will always run in modeDebug
since it will always be compiled in this format for you to proceed with the tests.– Felipe Assunção
The contents of the folder
bin/Release
is generated by release mode.– Jéf Bueno