如何解决此错误。
问题描述:
您好,
如何解决此错误 -
a gdi + image中发生一般性错误。保存c#(ExternalException)
Hello,
How to resolve this error-
a generic error occurred in gdi+ image.save c# (ExternalException)
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(MemoryStream stream)
at System.Drawing.ImageConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType)
at System.ComponentModel.TypeConverter.ConvertTo(Object value, Type destinationType)
at Vint3D.AdminPanel.ImageToByte(Image img) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Vint3D\Vint3D\AdminPanel.cs:line 29
at Vint3D.AdminPanel.btnRenameTile_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Vint3D\Vint3D\AdminPanel.cs:line 753
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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Vint3D.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects\Vint3D\Vint3D\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
请帮助我,更新图片时显示此错误。
谢谢。
Ankit Agarwal
软件工程师
please help me, when update image so this error was showing.
Thank You.
Ankit Agarwal
Software Engineer
答
为什么当你可以调用保存(字符串文件名,ImageFormat格式)
图像
的方法时,你会调用ImageToByte和这样的伏都教吗? ?保持简单可以减少出错的可能性。
Why do you call ImageToByte and such voodoo when you could just call theSave(string filename, ImageFormat format)
method ofImage
? Keeping things simple will reduce the chances of errors.