The question of the proposed
In the evening, turning over the chat in the group, I found an interesting question: how can I use encoding to determine whether a DLL or EXE is a debug build or a release build? There was not much discussion, so I had to find some way to try to solve the problem and bring some excitement to the nightlife. Then, there is the exploration and analysis of this article.
Of course, in order to fully mobilize everyone's ideas, eliminating unnecessary Google operations, I think it is necessary to debug and release two models of similarities and differences to do a little sketchy analysis, so as to lay a good foundation for the next solution.
Debug & Release
When we applied Visual Studio to F5 operations on code files (build), there was actually a series of syntax checks, lexical checks, and compilation processes, and typically we had two builds modes, which is often said to be the debug build and release built. As you know, the debug build pattern is typically applied to development, which facilitates debugging feedback, and release builds apply to deployment, because the compiler does a lot of optimization (code redundancy, loop optimization, and so on) in release mode, eliminating the need to record debug information. Therefore, the two build patterns are different, and we have a little summary of both of them as follows:
When debug is used for development, release is used for deployment.
In debug mode, a PDB file is generated to hold state information and debug information, and in release mode, no debugging information or PDB files are generated.
In debug mode, System.Diagnostics.Debug.Write (or WriteLine) can output trace information to the trace window (output), and System.Diagnostics.Debug.WriteLine will be ignored in release mode. However, can consider System.Diagnostics.Trace.Write, its popularity is good, to debug and release about take-all, can output debugging information.
In debug mode, #define DEBUG participates in the compilation process as a default predefined constant, and in release mode, the precompilation is omitted. For example, if you do:
#if DEBUG
Console.WriteLine("Hi");
#endif
In debug mode, Console.WriteLine ("Hi") will participate in the compilation, and the execution of the statement is ignored in release mode. However, if you manually add
#define DEBUG
In both modes, the compilation of Console.WriteLine ("Hi") is performed. The reason for this is that Visual Studio has predefined #define DEBUG by default, and we can set it by using the switch:
For a precompiled directive, you can look at the relevant chapters of. NET you must know.