473,606 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception when saving an imagefile

2 New Member
Hello.
I have a problem-saving an image file using c# in Windows Forms App. Environment MS visual and windows 11.

Clip of code where exception appears.(I clipped what I believe is the involved part).
Expand|Select|Wrap|Line Numbers
  1.  private void saveImage2()
  2.         {
  3.             if (System.IO.File.Exists(@"D:\bilder\temp.png"))
  4.                   System.IO.File.Delete(@"D:\bilder\temp.png");
  5.            MG.bmp.Save(@"D:\bilder\temp.png", ImageFormat.Png); // exception appears at this line.
  6.             // Dispose of the image files.
  7.           //  MG.bmp.Dispose();
  8.         }
The MG.bmp is a global variable Bitmap bmp which is located in the internal class.(MG).
I use it every time I update image content and others.

Here is the exception text:
System.NullRefe renceException
HResult=0x80004 003
Message=Object reference not set to an instance of an object.
Source=ark
StackTrace:
at ark.Form1.saveI mage2() in C:\Users\xxxxx\ source\repos\bo k\ark\Form1.cs: line 1150

Can someone kindly help me get the exception devil off my back after 5 hours of knocking my head?
Thank You.
Apr 14 '22 #1
0 7701

Sign in to post your reply or Sign up for a free account.

Similar topics

14
12158
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following line in xslt <xsl:value-of select="/blah/q" /> and my xml document does not have a node /blah/q. The output would
4
48202
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+. System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
2
2120
by: Roman Muntyanu | last post by:
Hi All, I got exception when call Activator.GetObject( ... ) When I start my application I register Channel to communicate between two computers and register type ReceiverLocator for remoting in Bind() Then when I need to get reference to this object on remote computer I call Lookup and get proxy from remote computer. Lookup() works fine when I start MyApplication.exe from current
1
5128
by: terrorix | last post by:
I want to save uploaded file to disk. I have this construction: HttpPostedFile myFile = ((HttpRequest)Request).Files; if (myFile != null) { string fn = "c:\\Inetpub\\wwwroot\\MyWeb\\upload\\File_1"; try { myFile.SaveAs(fn); lblMsg.Text = "File was uploaded and saved successfully!";
2
1762
by: darrel | last post by:
I have written an image upload/resize tool that then saves out the image as either a JPG or GIF. I got the JPG save working nicely, using a codec and setting the compression to 90%. However, I can't seem to manipulate the GIF using the same parameter. All my GIFs appear to be using a restricted pallette (reduced windows system?) and they all come out incredibly grainy. Is there away to change the color pallet the GIF uses when...
5
4485
by: Matt | last post by:
Hi all, I'm having a very strange problem. The third line in the following code gives me a null reference exception when used in an ASP.Net web page. The code is called on the click of a button. Public Overridable Property SDSVarsSetup() As Boolean Get If Not IsNothing(Session("SDSVarsSetup")) Then ' <-- **Exception occurs here**
1
1987
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in system.drawing.dll Additional information: A generic error occurred in GDI+.
0
2103
by: webbsk | last post by:
I keep getting an exception when I call the DataAdapter Update method. I have been trying to figure out what is causing the null reference exception for this code for what seems like forever: private void DoInserts(OdbcDataAdapter odbcDataAdapter, string tableName) { DataTable dataTableChanged = dsTapes.Tables.GetChanges(DataRowState.Added);
0
1329
by: Tony K | last post by:
ERROR MESSAGE RECEIVED WHEN SAVING. "The operation could not be completed. No such interface supported." Dell Inspirion E1705, 1GB RAM, Windows Vista Ultimate I can start debugging and the website appears in my browser with pics so that tells me that data is being retrieved from the db file. Not sure what is going on. I receive this error when saving a new website. This one in particular is a starter kit for the Business website. I...
4
4470
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is selected, the row is added using JavaScript. The script uses cloneNode to clone a hidden template row and all of its children and then adds the new row to the table, updates all of the child control Ids and sets visibility etc. The hidden...
0
7939
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8432
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8428
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6753
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.