Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. OpenFileDialog exceptions

OpenFileDialog exceptions

Scheduled Pinned Locked Moved Windows Forms
sysadmindebuggingperformancehelptutorial
10 Posts 5 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MannyTheMammoth
    wrote on last edited by
    #1

    Hi All! The standard OpenFileDialog throws exceptions when I call its ShowDialog method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.

    public AForm()
    {
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.ShowDialog(); //The exceptions are thrown from here
    }

    Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!

    L L Peric ZeljkoP 4 Replies Last reply
    0
    • M MannyTheMammoth

      Hi All! The standard OpenFileDialog throws exceptions when I call its ShowDialog method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.

      public AForm()
      {
      OpenFileDialog ofd = new OpenFileDialog();
      ofd.ShowDialog(); //The exceptions are thrown from here
      }

      Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think you may have to check some of the initialisation values are set correctly; see here[^] for more details. [edit] I have reproduced the code exactly as above and it works fine, so I must assume the actual eception is caused somewhere else, and it just appears to be at that point. Can you explain how you are so sure it is caused by the ShowDialog() method? [/edit]

      Unrequited desire is character building. OriginalGriff

      M 1 Reply Last reply
      0
      • M MannyTheMammoth

        Hi All! The standard OpenFileDialog throws exceptions when I call its ShowDialog method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.

        public AForm()
        {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.ShowDialog(); //The exceptions are thrown from here
        }

        Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Looks more like your memory has become corrupted. You're not running the method from a different thread, are you?

        Bastard Programmer from Hell :suss:

        M 1 Reply Last reply
        0
        • M MannyTheMammoth

          Hi All! The standard OpenFileDialog throws exceptions when I call its ShowDialog method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.

          public AForm()
          {
          OpenFileDialog ofd = new OpenFileDialog();
          ofd.ShowDialog(); //The exceptions are thrown from here
          }

          Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          There shouldn't be any problems provided your main method is managed, has the [STAThread] attribute, and you create your AForm instance(s) from the main thread. If you deviate from this path, you are set for trouble with COM objects such as OpenFileDialog. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          M 1 Reply Last reply
          0
          • M MannyTheMammoth

            Hi All! The standard OpenFileDialog throws exceptions when I call its ShowDialog method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.

            public AForm()
            {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.ShowDialog(); //The exceptions are thrown from here
            }

            Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!

            Peric ZeljkoP Offline
            Peric ZeljkoP Offline
            Peric Zeljko
            wrote on last edited by
            #5

            public MainForm()
            {
            InitializeComponent();

               OpenFileDialog ofd = new OpenFileDialog();
               ofd.ShowDialog(); //The exceptions are thrown from here
            		
            }
            

            I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:

            public AForm()
            {
            // calling subprogram
            Openfiledialog();
            }

            void Openfiledialog()
            {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.ShowDialog(); //The exceptions are thrown from here
            }

            If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)

            D M 2 Replies Last reply
            0
            • Peric ZeljkoP Peric Zeljko

              public MainForm()
              {
              InitializeComponent();

                 OpenFileDialog ofd = new OpenFileDialog();
                 ofd.ShowDialog(); //The exceptions are thrown from here
              		
              }
              

              I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:

              public AForm()
              {
              // calling subprogram
              Openfiledialog();
              }

              void Openfiledialog()
              {
              OpenFileDialog ofd = new OpenFileDialog();
              ofd.ShowDialog(); //The exceptions are thrown from here
              }

              If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)

              D Offline
              D Offline
              DaveyM69
              wrote on last edited by
              #6

              Kudos for answering, but please place code inside a pre block either by using the code widget or manually using <pre> ... </pre> around the code. You can still do this by editing your response. I would not post your email address publicly in an online forum unless you really like spam!

              Dave
              Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
              BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

              1 Reply Last reply
              0
              • L Lost User

                Looks more like your memory has become corrupted. You're not running the method from a different thread, are you?

                Bastard Programmer from Hell :suss:

                M Offline
                M Offline
                MannyTheMammoth
                wrote on last edited by
                #7

                No I'm not, I call it from the main thread. The Control.InvokeRequired method returns always false.

                1 Reply Last reply
                0
                • L Lost User

                  I think you may have to check some of the initialisation values are set correctly; see here[^] for more details. [edit] I have reproduced the code exactly as above and it works fine, so I must assume the actual eception is caused somewhere else, and it just appears to be at that point. Can you explain how you are so sure it is caused by the ShowDialog() method? [/edit]

                  Unrequited desire is character building. OriginalGriff

                  M Offline
                  M Offline
                  MannyTheMammoth
                  wrote on last edited by
                  #8

                  It worked fine some time ago... You're right the exception could be caused somewhere else. I tested to disable only the ShowDialog() method call and it worked fine. No exceptions. When you ran the code, did you activate the "Unmanaged code debuging"?

                  1 Reply Last reply
                  0
                  • L Luc Pattyn

                    There shouldn't be any problems provided your main method is managed, has the [STAThread] attribute, and you create your AForm instance(s) from the main thread. If you deviate from this path, you are set for trouble with COM objects such as OpenFileDialog. :)

                    Luc Pattyn [My Articles] Nil Volentibus Arduum

                    M Offline
                    M Offline
                    MannyTheMammoth
                    wrote on last edited by
                    #9

                    That's exactly what I did :(

                    1 Reply Last reply
                    0
                    • Peric ZeljkoP Peric Zeljko

                      public MainForm()
                      {
                      InitializeComponent();

                         OpenFileDialog ofd = new OpenFileDialog();
                         ofd.ShowDialog(); //The exceptions are thrown from here
                      		
                      }
                      

                      I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:

                      public AForm()
                      {
                      // calling subprogram
                      Openfiledialog();
                      }

                      void Openfiledialog()
                      {
                      OpenFileDialog ofd = new OpenFileDialog();
                      ofd.ShowDialog(); //The exceptions are thrown from here
                      }

                      If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)

                      M Offline
                      M Offline
                      MannyTheMammoth
                      wrote on last edited by
                      #10

                      That was a good clue! I disabled my network adapter to check if the network could cause the problem and the OpenFileDialog worked fine! As my "My Documents" folder is stored on a remonte server, my computer uses the network connection to get the folder and files informations. Any idea why this could throw the exceptions I have? I'm not sure yet why I have those exceptions, but my code isn't faulty! ;P

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups