Following is a very simple program, extracted from my 'real' program. that demonstrates the problem. (For those interested, the jpg file is of dimension 200x200 - any jpg will work.) When I run the program within Visual Studio it works just fine. However, when I run the program stand-alone, I get an InteropServices.ExternalException error. I have searched on this and have tried a variety of things, but I keep getting the error.
Here is the 'entire' program:
Please modify this program such that it works as stand-alone. Many thanks.
Here is the 'entire' program:
Code:
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim imgLI As Image
imgLI = New Bitmap(Image.FromFile("C:\Users\Gerry\Desktop\SmileFace.jpg"), 150, 150)
Dim bmp As New Bitmap(250, 250)
Using bmp
Dim gr As Graphics = Graphics.FromImage(bmp)
gr.Clear(Color.WhiteSmoke)
gr.DrawImage(imgLI, 25, 25)
bmp.Save("C:\Users\Gerry\Desktop\foobar.jpg", ImageFormat.Jpeg)
gr.Dispose() ' this line before or after the above does not matter
End Using
Application.Exit()
End
End Sub
End Class