-
May 3rd, 2014, 10:06 AM
#1
PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
I am doing a project.With a button from PictureBox I want to take the help of webcam photographs, and want to save it to my computer.
This My codes;
Button1_Click(){
pictureBox1.Image.Save(string.Format(Application.S tartupPath+"\\Resimler\\kayit{0}.png",a,System.Dra wing.Imaging.ImageFormat.Png));
}
But it's not working. I'm constantly getting the error. Error: "Generic Error GDI+" , How can i solve this problem. Please Help, this my School project
Sorry for bad english
-
May 4th, 2014, 12:57 PM
#2
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Compute the value FIRST using a String variable. Make sure that it is correct, and then use it in the .Save event
-
May 4th, 2014, 02:37 PM
#3
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Firs of all , thanks for reply. I do not know too much C# , How would you do? For example, can you write? please
-
May 4th, 2014, 07:50 PM
#4
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by hknzq
Firs of all , thanks for reply. I do not know too much C# , How would you do? For example, can you write? please
Code:
button1_Click()
{
var filePath = String.Format(Application.StartupPath + "\\Resimler\\kayit{0}.png", a); // <-- what is 'a' in your code?
pictureBox1.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
}
Break out the file path as I've shown above. In your original code, you had the closing ')' for the String.Format call in the wrong place.
You also need to track down what 'a' is.
-
May 5th, 2014, 01:01 AM
#5
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by Arjay
Code:
button1_Click()
{
var filePath = String.Format(Application.StartupPath + "\\Resimler\\kayit{0}.png", a); // <-- what is 'a' in your code?
pictureBox1.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
}
Break out the file path as I've shown above. In your original code, you had the closing ')' for the String.Format call in the wrong place.
You also need to track down what 'a' is.
First of all, thanks for reply.
This my save button click() code;
if (txtAd.Text != "" && txtSoyad.Text != "" && txtTC.Text != "" && txtNo.Text != "" && txtBaba.Text != "" && txtBolum.Text != "" && txtGun.Text != "" && txtAy.Text != "" && txtYil.Text != "" && txtAdres.Text != "" && txtTel.Text != "")
{
button4.Enabled = true;
var filePath = String.Format(Application.StartupPath + "\\Resimler\\kayit{0}.png", a);
pictureBox1.Image.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
if (a == 2)
{
MessageBox.Show("En Fazla 2 Kare Çekebilirsiniz. Çıkıştuşuna basarak Kayıtların silip, yeniden oluşturabilirsiniz.", "UYARI!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
button4.Enabled = false;
}
label6.Text = (a.ToString()) + " Fotoğraf çekildi";
a = a + 1;
}
else { MessageBox.Show("Lütfen tüm gerekli alanları doldurunuz...", "UYARI!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
But This error;
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at KameradanGoruntuAlmak.Form1.button4_Click(Object sender, EventArgs e)
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.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
KameradanGoruntuAlmak
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/MK%DC%20%D6grenci%20Kayit%20Otomasyonu/MK%DC%20%D6grenci%20Kayit%20Otomasyonu/KameradanGoruntuAlmak.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
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.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
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.0.30319.1 (RTMRel.030319-0100)
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.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll
----------------------------------------
WebCam_Capture
Assembly Version: 1.0.2087.23475
Win32 Version: 1.0.2087.23475
CodeBase: file:///C:/Program%20Files/MK%DC%20%D6grenci%20Kayit%20Otomasyonu/MK%DC%20%D6grenci%20Kayit%20Otomasyonu/WebCam_Capture.DLL
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
-
May 5th, 2014, 10:22 AM
#6
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Use need to use the debugger to help you figure this out.
Put a breakpoint on the following line (click on the line and press F9)
Code:
pictureBox1.Image.Save(filePath,
Press F5 to start debugging.
When the debugger breaks on the breakpoint, hover the mouse over the filePath variable to see its contents.
Does it look like it's been formed correctly?
-
May 5th, 2014, 01:22 PM
#7
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by Arjay
Use need to use the debugger to help you figure this out.
Put a breakpoint on the following line (click on the line and press F9)
Code:
pictureBox1.Image.Save(filePath,
Press F5 to start debugging.
When the debugger breaks on the breakpoint, hover the mouse over the filePath variable to see its contents.
Does it look like it's been formed correctly?
In the project are working normally.
But after Setup on the computer when I install, I get this error. (
-
May 5th, 2014, 01:41 PM
#8
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by hknzq
In the project are working normally.
But after Setup on the computer when I install, I get this error. (
Add some code to verify that the path exists and that you have access to it. If you are trying to save a file to the location where your app has been installed you probably don't have access.
-
May 5th, 2014, 02:21 PM
#9
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by Arjay
Add some code to verify that the path exists and that you have access to it. If you are trying to save a file to the location where your app has been installed you probably don't have access.
thanks for reply,,
But I creating installation "Resimler" folder, I add in the program files. Access road section where the program is installed already, is not it?
-
May 5th, 2014, 04:18 PM
#10
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by hknzq
thanks for reply,,
But I creating installation "Resimler" folder, I add in the program files. Access road section where the program is installed already, is not it?
From what I said earlier:
If you are trying to save a file to the location where your app has been installed you probably don't have access.
When you install a program, your permissions get elevated.
When you run the program, the program runs under non-elevated permissions, so if you try to save a file in the same place the app has been installed, you probably won't have the required permissions.
To test this, run the app with administrator permissions. If you can save the file, it's a permissions issue. If you can't, it's something else.
-
May 7th, 2014, 08:20 AM
#11
Re: PictureBox Generic Error GDI+ Error Problem ! HELP PLEASE
Originally Posted by Arjay
From what I said earlier:
When you install a program, your permissions get elevated.
When you run the program, the program runs under non-elevated permissions, so if you try to save a file in the same place the app has been installed, you probably won't have the required permissions.
To test this, run the app with administrator permissions. If you can save the file, it's a permissions issue. If you can't, it's something else.
Thank you for everything Arjay !!
I solved this problem, Thanks to you. Only a compatibility issue. I'm using Windows 7 , and right-click on the program,"troubleshoot compatibility" option clicked. Windows XP Service Pack 2 compatibility did. And Problem Solved Thankssss
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|