Results 1 to 2 of 2

Thread: System.InvalidOperationException was unhandled

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2009
    Posts
    47

    System.InvalidOperationException was unhandled

    I got the error after I added forms from another project into a new project. Theres no error in my code so it doesn't show where the error occurred.. Could someone help me out and explain what this exception means please?

    Code:
    System.InvalidOperationException was unhandled
      Message="An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object."
      Source="Project1"
      StackTrace:
           at Project1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190    
    	   at Project1.My.MyProject.MyForms.get_Project1Main()    
    	   at Project1.Project1Main.Main() in C:\Project1\Project1Main.vb:line 7    
    	   at System.AppDomain._nExecuteAssembly(Assembly 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)    
    	   at System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.NullReferenceException
           Message="Object reference not set to an instance of an object."
           Source="System.Windows.Forms"
           StackTrace:
                at System.Windows.Forms.Cursor..ctor(Stream stream)    at Project1.Project1Main..ctor() in C:\Project1\Project1Main.vb:line 395
           InnerException:

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: System.InvalidOperationException was unhandled

    Now's a good chance to learn how to read a stack trace. Each line that begins with "at" is a method call. If there's an InnerException it means that an exception has been thrown in one place, caught in another, wrapped in a new exception and then that has been thrown. It's that outer exception that you're being notified of, but it includes information about the original exception that caused it.

    Look at the InnerException part of your stack trace. It says that a NullReferenceException occurred in the Cursor constructor that takes a Stream argument. Does your main form perhaps use a custom cursor that was defined in the old project but not in the new one?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width