static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SpaceInvaders());// i get an error here when i start the form application.. it says Argument Exception. Parameter is not valid
}
私のメインフォームは次のようになります。
public SpaceInvaders()
{
InitializeComponent();
}
public void SpaceInvaders_Load(object sender, EventArgs e)
{
}
ここにスタックトレースがあります
" System.Drawing.Graphics.GetHdc() で\r\n System.Drawing.BufferedGraphics.RenderInternal(HandleRef refTargetDC, BufferedGraphics buffer) で\r\n System.Drawing.BufferedGraphics.Render() で\r\n システムで.Windows.Forms.Control.WmPaint(Message& m)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r \n System.Windows.Forms.ContainerControl.WndProc(Message& m)\r\n System.Windows.Forms.Form.WndProc(Message& m)\r\n System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam )\r\n System.Windows.Forms.UnsafeNativeMethods.System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) で \r\n System.Windows で DispatchMessageW(MSG& msg)\r\n。 Forms.Application.ThreadContext.RunMessageLoopInner(Int32 理由、ApplicationContext コンテキスト)\r\n で System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 理由、ApplicationContext コンテキスト)\r\n で System.Windows.Forms.Application. Run(Form mainForm)\r\n D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\SpaceInvaders\SpaceInvaders\Program.cs:line 18 の WindowsFormsApplication1.Program.Main() で\r\n System.AppDomain._nExecuteAssembly で (アセンブリ アセンブリ、String[] args)\r\n System.AppDomain.ExecuteAssembly で (String assemblyFile、Evidence assemblySecurity、String[] args)\r\n Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() で\r\n System.Threading.ThreadHelper.ThreadStart_Context(Object state) で\r\n System.Threading.ExecutionContext.Run( ExecutionContext executionContext、ContextCallback コールバック、オブジェクト状態)\r\n at System.Threading.ThreadHelper.ThreadStart()"
「パラメータが無効です。」
私は問題を見つけたと思います:
public void Draw(Graphics g,int animationCell)
{
// some code
g.dispose()//that method threw the exception can someone tell me why? i thought you do need to dispose your graphics object at the end when you finish using it.
}