Skip to main content

Microsoft Silverlight

Unanswered Question OpenFileDialog throws exception when lots of files are selectedRSS Feed

(0)

Gicanu
Gicanu

Member

Member

0 points

3 Posts

OpenFileDialog throws exception when lots of files are selected

Hello,

I have a Silverlight control hosted in an asp.net web application, that calls the following code when a button is clicked:

OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;

if (ofd.ShowDialog() == true)
{  ..... }

 When I select a large number of files (800+) the ShowDialog() mehtod throws the following exception:

  {System.InvalidOperationException: ShowDialog failed.
   at System.Windows.Controls.OpenFileDialog.ShowDialog()
   at mpost.SilverlightMultiFileUpload.Page.SelectUserFiles()
   at mpost.SilverlightMultiFileUpload.Page.SelectFilesButton_Click(Object sender, RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)}

Does anyone know how can I make it possible to open so many files?

From what I could find on the internet, there is some buffer that has to be set higher, but I could not find what is the exact setting in Web.config I have to modify.

 Thanks,

 Gicanu

 

 

prujohn
prujohn

Contributor

Contributor

3567 points

703 Posts

Re: OpenFileDialog throws exception when lots of files are selected

Just out of curiousity, what is your use-case scenario for needing to open so many files at one time?

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: OpenFileDialog throws exception when lots of files are selected

I just tried with 2210 files from System32 folder. it's working fine.

XAML

<UserControl x:Class="SilverlightApplication1.MainPage"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">

<Grid x:Name="LayoutRoot">

<Button Content="Click Me" Click="Button_Click"></Button>

</Grid>

</UserControl>

C#

public partial class MainPage : UserControl

{

public MainPage()

{

InitializeComponent();

}

private void Button_Click(object sender, RoutedEventArgs e)

{

OpenFileDialog ofd = new OpenFileDialog();

ofd.Multiselect = true;

if (ofd.ShowDialog() == true)

{

}

}

}

}

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


Gicanu
Gicanu

Member

Member

0 points

3 Posts

Re: Re: OpenFileDialog throws exception when lots of files are selected

I have no problem in satisfying your curiosity. The Silverlight control is part of an app that submits all this files to a printing server which has no problem in dealing with thousands of files.

Gicanu
Gicanu

Member

Member

0 points

3 Posts

Re: OpenFileDialog throws exception when lots of files are selected

 Thanks for the answer.

Can you tell me please what version of Silverlight and what browser you used?

Thanks

sl.ayer
sl.ayer

Participant

Participant

848 points

162 Posts

Re: OpenFileDialog throws exception when lots of files are selected

btw. web.config got nothing to do with silverlight.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities