locked
Application can not run if built in Release mode, Debug mode runs fine RRS feed

  • Question

  • Hi all,

    Currently i have encountered a very strange issue with working in vs2010 environment.

    I have a project written in vb.net which runs fine if i compile in debug mode. However it will crash at some point after running if i compile it in Release mode.

    I have double checked all the conditional debug code (#if debug) and they look correct. They are just needed to show some information while debugging.

    I also created 'devenv.exe.config' config file with contents:

    <?xml version ="1.0"?>
    <configuration>
        <runtime>       
            <loadFromRemoteSources enabled="true" />
        </runtime>
    </configuration>

    I have tried all suggestions that people posted on the internet but still no hope. Same dependencies and dlls are used for both builds.

    Below is what i get from the error Description:

    System.Exception: Critical Error, CBS must exit. ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at DevExpress.XtraBars.BarItemLink.OnLinkClick()
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at CBS.Startup.SingleInstanceController.Run(String[] args) in C:\Projects\VS2010\CBS\CBS\Startup\SingleInstanceController.vb:line 138
       at CBS.Startup.StartUp.Start() in C:\Projects\VS2010\CBS\CBS\Startup\StartUp.vb:line 29
       --- End of inner exception stack trace ---

    Please tell me if you have any suggestions


    • Edited by douglasle Monday, October 31, 2011 8:16 AM
    Monday, October 31, 2011 7:45 AM

Answers

  • Hi douglasle,

    Generally speaking, the difference between the debug and the releases build is that:
    In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account.
    While in release build the symbolic debug info is not emitted and the code execution is optimized.
    Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable.

    You can try the following solutions:

    1.       If you try to create a new project, see whether this issue still exists. Sometimes corrupted project settings can cause problems.  And not caused by VS IDE.

    2.       Try deleting the references to the libraries and re-adding them. Then rebuild under release mode.

    See if the following related threads are helpful:

    Program not working in 'Release mode' but works in 'Debug mode'

    http://www.codeguru.com/forum/showthread.php?t=464268

    Why Program works in debug but not release mode

    http://social.msdn.microsoft.com/forums/en-us/vclanguage/thread/1CE70392-5E84-4FCB-925D-F8ACB47A030D

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by lucy-liu Monday, November 7, 2011 9:16 AM
    Tuesday, November 1, 2011 3:32 AM