OpenFileDialog.ShowDialog()引发异常?
|
我试图显示一个来自WPF视图模型命令的对话框,但是当我调用call0ѭ时会抛出
System.ArgumentException
,我想知道是否有人可以提示我原因?
这是我的代码:
Public ReadOnly Property OpenParser As ICommand
Get
Return New RelayCommand(Sub(param As Object) OpenParserExecute(DirectCast(param, Frame)))
End Get
End Property
Public Sub OpenParserExecute(ByVal mFrame As Frame)
SaveParserExecute()
Dim mOpenDialog As OpenFileDialog = OpenDialog
If mOpenDialog.ShowDialog() Then \' Lines the throws the exception
CurrentParser = New ParserEditorModel(mOpenDialog.FileName)
mFrame.Navigate(New ParserEditor(CurrentParser))
End If
End Sub
根据要求的StackTrace:
at MS.Internal.Interop.HRESULT.ThrowIfFailed(String message)
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()
at WinTransform.GUI.MainWindowModel.OpenParserExecute(Frame mFrame) in C:\\Users\\Alex\\Desktop\\MEDLI\\branches\\WinTransform\\GUI\\ViewModels\\MainWindowModel.vb:line 38
没有找到相关结果
已邀请:
1 个回复
播匣扦阔食
本身返回
,而您的
语句期望一个不可为空的
。 您必须将对话框的返回值转换为
,如果是
,则通过对话框的
属性返回所选文件。 例。