Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9096791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:56:42+00:00 2026-06-16T23:56:42+00:00

I’m getting reports from a WPF application that is deployed in the field that

  • 0

I’m getting reports from a WPF application that is deployed in the field that the following ArgumentException is being thrown when attempting to display an Open File Dialog.

Exception Message:   Value does not fall within the expected range.
Method Information:  MS.Internal.AppModel.IShellItem2 GetShellItemForPath(System.String)
Exception Source:    PresentationFramework
Stack Trace
  at MS.Internal.AppModel.ShellUtil.GetShellItemForPath(String path)
  at Microsoft.Win32.FileDialog.PrepareVistaDialog(IFileDialog dialog)
  at Microsoft.Win32.FileDialog.RunVistaDialog(IntPtr hwndOwner)
  at Microsoft.Win32.FileDialog.RunDialog(IntPtr hwndOwner)
  at Microsoft.Win32.CommonDialog.ShowDialog(Window owner)
  ...

The problem is that so far I haven’t been able to replicate this in my development environment but I have received several reports from the field that this exception is occurring.

Has anyone seen this before? And most importantly do you know the cause and/or a fix for it other than just simply putting a try/catch around it and instructing the user to try again whatever it is they were trying to do?

In response to a comment, this is the code that opens the dialog (and no, it was not a problem of checking the return type). The exception is thrown from within ShowDialog (see stack trace):

Nullable<bool> result = null;

var dlg = new Microsoft.Win32.OpenFileDialog();
dlg.DefaultExt = ".txt";
dlg.Filter = "Text Files (.txt)|*.txt|All Files|*.*";
dlg.Title = "Open File";
dlg.Multiselect = false;
dlg.InitialDirectory = GetFolderFromConfig("folders.templates");
result = dlg.ShowDialog(Window.GetWindow(this));

if (result == true)
{
    // Invokes another method here..
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:56:43+00:00Added an answer on June 16, 2026 at 11:56 pm

    This should really go to @Hans Passant as he pointed me in the right direction.

    It turns out the problem was trivial to replicate (and fix) on my development computer once I figured out what the problem really was. It turns out that the issue was indeed the InitialDirectory property being set to some odd value. in my case I was able to replicate the issue by setting InitialDirectory to “\”;

    Here’s the modified code to address the issue:

     try
     {
         result = dlg.ShowDialog(Window.GetWindow(this));
     }
     catch{
         dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
         result = dlg.ShowDialog(Window.GetWindow(this));
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.