Results 1 to 3 of 3

Thread: Bitmap.Save - how do I overcome an InteropServices.ExternalException error?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    103

    Question Bitmap.Save - how do I overcome an InteropServices.ExternalException error?

    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:
    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
    Please modify this program such that it works as stand-alone. Many thanks.

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Bitmap.Save - how do I overcome an InteropServices.ExternalException error?

    Is this something as simple as you aren't running your .exe file with elevated privileges and therefore the attempt to store the file on your desktop is failing because of that?

    Right-click the .exe file and choose "Run as Administrator" (or words to that effect) and see if that makes a difference.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    103

    Re: Bitmap.Save - how do I overcome an InteropServices.ExternalException error?

    OptionBase1 - Good idea, but I did as you suggested and got the same error...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width