<p>When should I include PDB files for a production release? Should I use the <code>Optimize code</code> flag and how would that affect the information I get from an exception?</p>

<p>If there is a noticeable performance benefit I would want to use the optimizations but if not I'd rather have accurate debugging info. What is typically done for a production app?</p>

[{'answer_id': 41871, 'author': 'Duncan Smart', 'author_id': 1278, 'author_profile': 'https://Stackoverflow.com/users/1278', 'pm_score': 5, 'selected': True, 'text': '<p>When you want to see source filenames and line numbers in your stacktraces, generate PDBs using the pdb-only option. Optimization is separate from PDB generation, i.e. you can optimize <em>and</em> generate PDBs without a performance hit.</p>\n\n<p>From <a href="http://msdn.microsoft.com/en-us/library/8cw0bt21(VS.80).aspx" rel="noreferrer">the C# Language Reference</a></p>\n\n<blockquote>\n  <p>If you use /debug:full, be aware that there is some impact on the speed and size of JIT optimized code and a small impact on code quality with /debug:full. We recommend /debug:pdbonly or no PDB for generating release code.</p>\n</blockquote>\n'}, {'answer_id': 41874, 'author': 'Rob Walker', 'author_id': 3631, 'author_profile': 'https://Stackoverflow.com/users/3631', 'pm_score': 2, 'selected': False, 'text': '<p>There is no need to include them in your distribution, but you should definitely be building them and keeping them. Otherwise debugging a crash dump is practically impossible.</p>\n\n<p>I would also turn on optimizations. Whilst it does make debugging more difficult the performance gains are usually very non-trivial depending on the nature of the application. We easily see over 10x performance on release vs debug builds for some algorithms.</p>\n'}, {'answer_id': 96261, 'author': 'HTTP 410', 'author_id': 13118, 'author_profile': 'https://Stackoverflow.com/users/13118', 'pm_score': 4, 'selected': False, 'text': '<p>To answer your first question, you only need to include PDBs for a production release if you need line numbers for your exception reports. </p>\n\n<p>To answer your second question, using the "Optimise" flag with PDBs means that any <a href="http://tinyurl.com/6khhkq" rel="nofollow noreferrer">stack "collapse" will be reflected in the stack trace</a>. I\'m not sure whether the actual line number reported can be wrong - this needs more investigation.</p>\n\n<p>To answer your third question, you can have the best of both worlds with a rather neat trick. The major differences between the default debug build and default release build are that when doing a default release build, optimization is turned on and debug symbols are not emitted. So, in four steps:</p>\n\n<ol>\n<li><p>Change your release config to emit debug symbols. This has virtually no effect on the performance of your app, and is very useful if (when?) you need to debug a release build of your app. </p></li>\n<li><p>Compile using your new release build config, i.e. <em>with</em> debug symbols and <em>with</em> optimization. Note that 99% of code optimization is done by the JIT compiler, not the language compiler.</p></li>\n<li><p>Create a text file in your app\'s folder called xxxx.exe.ini (or dll or whatever), where xxxx is the name of your executable. This text file should initially look like:</p>\n\n<pre><code>[.NET Framework Debugging Control]\nGenerateTrackingInfo=0\nAllowOptimize=1\n</code></pre></li>\n<li><p>With these settings, your app runs at full speed. When you want to debug your app by turning on debug tracking and possibly turning off (CIL) code optimization, just use the following settings:</p>\n\n<pre><code>[.NET Framework Debugging Control]\nGenerateTrackingInfo=1\nAllowOptimize=0 \n</code></pre></li>\n</ol>\n\n<p><strong>EDIT</strong> According to cateye\'s comment, <a href="http://martin.bz/blog/asp-net-mvc-source-debugging-the-easy-way" rel="nofollow noreferrer">this can also work in a hosted environment</a> such as ASP.NET.</p>\n'}]
['https://Stackoverflow.com/questions/41842', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3615/']