【发布时间】:2019-10-17 12:39:51
【问题描述】:
当我尝试创建新的位图图像以传递给方法时,我遇到了这个奇怪的问题。 异常发生在
位图 bm = new bitmap("images/cat.jpg");
我尝试使用各种大小的各种图像来尝试测试是否是文件大小问题,但结果表明项目中只有 1 个现有图像可以工作(这是一张猫的照片)。
所有其他图像都返回错误“参数无效”。我尝试重建项目并允许读取权限,但我仍然无法让它工作。
System.ArgumentException was unhandled
HResult=-2147024809
Message=Parameter is not valid.
Source=System.Drawing
StackTrace:
at System.Drawing.Bitmap..ctor(String filename)
at Image_Authentication_Final.RegistrationForm.btnRegister_Click(Object sender, EventArgs e) in c:\Users\Acc\Desktop\Image Authentication Final\Image Authentication Final\RegistrationForm.cs:line 176
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 MetroFramework.Controls.MetroButton.OnMouseUp(MouseEventArgs e)
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 Image_Authentication_Final.Program.Main() in c:\Users\Acc\Desktop\Image Authentication Final\Image Authentication Final\Program.cs:line 19
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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
【问题讨论】:
-
@dbc 刚试了下,完全不行……
-
刚刚尝试使用完全相同的图像,复制它并将第二个副本重命名为 cat2.jpg.. 如果我将该图像放入位图中,它会返回错误,这是什么?!跨度>
-
这
Bitmap bmp = new Bitmap("images/cat.jpg");是您在创建位图时所做的一切,还是您正在使用未显示的其他参数? -
您是否可以将其中一张在 zip 中无法使用的图片上传到 sendspace 之类的?