How come errors show when application in built in "Release" mode and don't when built in "Debug" mode

Mark McCumber 431 Reputation points
2023-07-13T16:15:36.83+00:00

I have developed an application in Visual Studio 2017, Visual Basic to be exact and I am confused. I developed the program and built it in debug mode to test out the application. The build process shows no errors, warnings, or messages and the program executes as designed. However, when I rebuild the project in release mode I get the exception:

Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
System.IO.FileNotFoundException: C:\Users\Quecu\source\repos\Dyn_DE_Tool_v3\Dyn_DE_Tool_v3\bin\Release\Save.bmp
   at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
   at Dyn_DE_Tool_v3.FrmMain.CtrlNavigator_OleDB(BindingNavigator ctrl, String strImgPath) in C:\Users\Quecu\source\repos\Dyn_DE_Tool_v3\Dyn_DE_Tool_v3\frmMain.vb:line 173
   at Dyn_DE_Tool_v3.FrmMain.BtnFrmTbl_Click(Object sender, EventArgs e) in C:\Users\Quecu\source\repos\Dyn_DE_Tool_v3\Dyn_DE_Tool_v3\frmMain.vb:line 267
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4645.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Dyn_DE_Tool_v3
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Quecu/source/repos/Dyn_DE_Tool_v3/Dyn_DE_Tool_v3/bin/Release/Dyn_DE_Tool_v3.exe
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4644.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4550.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4644.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4190.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4644.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
Microsoft.VisualBasic
    Assembly Version: 10.0.0.0
    Win32 Version: 14.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System.Transactions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.EnterpriseServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Numerics
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------

************** JIT Debugging **************
Application does not support Windows Forms just-in-time (JIT)
debugging. Contact the application author for more information.

I don’t understand why. There should be no difference between Debug and Release.

So why is this happening?

Thank you,

MRM256

Developer technologies | VB
0 comments No comments
{count} votes

Accepted answer
  1. Dewayne Basnett 1,381 Reputation points
    2023-07-14T17:28:09.1166667+00:00

    Add the image as a resource. In the code you'll need a few few changes,

            PictureBox1.Image = My.Resources.Save 'don't need extension
            ' OR
            Dim img As Image = My.Resources.Save
            PictureBox1.Image = img
    
    

    User's image


2 additional answers

Sort by: Most helpful
  1. Andy De George 90 Reputation points Microsoft Employee
    2023-07-13T16:31:03.88+00:00

    Hi! That error is saying that the Save.bmp file is missing from the output folder. Debug and Release modes go to different folders. You probably manually copied the Save.bmp file to the debug folder at some point. You should instead add the Save.bmp file to your project, select it in the Solution Explorer window, and then in the Properties window set Copy to output folder to Always.

    1 person found this answer helpful.

  2. Andy De George 90 Reputation points Microsoft Employee
    2023-07-13T16:31:49.44+00:00

    Posted a second time to get my first post to show up...

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.