Adgang til filer i WPF
Jeg har lavet en WPF-applikation, som benytter Windows Forms. Formen hoster en activeX-control, som jeg i tidligere implementeringer af WPF fik til at virke.WPF-applikationen indeholder en fil-vælger til det lokale filsystem. Handleren til knapper ser således ud:
private void btnLoadFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
if (dialog.ShowDialog(this).Value)
{
activeXcontrol.url = dialog.FileName;
}
}
I Window1.xaml kommer der en fejl i designet, som ser således ud:
String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.Windows.Forms.AxHost.TypeLibraryTimeStampAttribute..ctor(String timestamp)
at System.Reflection.CustomAttribute._CreateCaObject(Void* pModule, Void* pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(Module module, RuntimeMethodHandle ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, RuntimeType caType)
at System.Reflection.Assembly.GetCustomAttributes(Boolean inherit)
at MS.Internal.Xaml.ReflectionProjectNode.BuildNamespaces()
at MS.Internal.Xaml.ReflectionProjectNode.ParseClrNamespaceUri(Identifier namespaceId, Identifier name, String clrNamespaceUri, IParseContext context, Node offendingNode)
at MS.Internal.Xaml.ReflectionProjectNode.EnsureExists(Identifier namespaceUri, Identifier name, IParseContext context, Node offendingNode)
at MS.Internal.Xaml.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
at MS.Internal.Xaml.XmlElement.FindElementType(PrefixScope parentScope, IParseContext context)
at MS.Internal.DocumentTrees.Markup.XamlSourceDocument.get_RootType()
at Microsoft.Windows.Design.Documents.Trees.MarkupDocumentTreeManager.get_RootType()
at Microsoft.Windows.Design.Documents.MarkupDocumentManager.CalculateLoadErrorState()
at Microsoft.Windows.Design.Documents.MarkupDocumentManager.get_LoadState()
at MS.Internal.Host.PersistenceSubsystem.Load()
at MS.Internal.Host.Designer.Load()
at MS.Internal.Designer.VSDesigner.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()
Jeg har forsøgt, at sætter sikkerheden i applikationen til minimal, så man under alle omstændigheder har adgang til filsystemet. Men ved kørsel af applikationen, når filen er valgt gennem FileDialog, så kommer denne fejl:
WARNING: Cannot load ../../Basic/course/...
Er der nogle, som har nogle forslag til, hvordan jeg får løst dette problem?