开发者

Code to be executed only when application is run outside of visual studio?

开发者 https://www.devze.com 2023-01-11 07:41 出处:网络
I have a WPF windows application that makes a call to a DLL for registration. I need this code to be called only when the application is run outside of visual studio.

I have a WPF windows application that makes a call to a DLL for registration. I need this code to be called only when the application is run outside of visual studio. In other words, when clicking run from within the visual studio, I dont want this code executed but want it executed if EXE is called outside of visual studio.

Is there a开发者_StackOverflow way where I can do that withouht having to keep commenting and uncommenting this code?


you could use the preprocessor:

#if DEBUG
   code to run during debug mode only
#else
   normal code
#endif

or the Conditional attribute

[Conditional("DEBUG")]
private void SomeMethod()
{
 stuff
}
0

精彩评论

暂无评论...
验证码 换一张
取 消