i have created an app which i used C# But every time i want to run it on domain its doesnt open the form but in task manager its showing

Isaac Mhango 0 Reputation points
2025-07-30T07:20:31.9566667+00:00

Application: DcmFolderScan.exe

CoreCLR Version: 8.0.1825.31117

.NET Version: 8.0.18

Description: The process was terminated due to an unhandled exception.

Exception Info: System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'DcmFolderScan.MainWindow' that matches the specified binding constraints threw an exception.

---> System.UnauthorizedAccessException: Access to the path 'H:\System Volume Information' is denied.

at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)

at System.IO.Enumeration.FileSystemEnumerator`1.Init()

at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)

at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)

at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)

at System.IO.Directory.GetFiles(String path, String searchPattern, EnumerationOptions enumerationOptions)

at DcmFolderScan.MainWindow.GetDcmStudyFromFolder(String directory) in C:\DcmFolderScan12\DcmFolderScan\MainWindow.xaml.cs:line 236

at DcmFolderScan.MainWindow.ScanFolder() in C:\DcmFolderScan12\DcmFolderScan\MainWindow.xaml.cs:line 188

at DcmFolderScan.MainWindow..ctor() in C:\DcmFolderScan12\DcmFolderScan\MainWindow.xaml.cs:line 83

at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

--- End of inner exception stack trace ---

at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)

at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)

at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)

at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)

at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)

at System.Windows.Application.DoStartup()

at System.Windows.Application.<.ctor>b__1_0(Object unused)

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

at System.Windows.Threading.DispatcherOperation.InvokeImpl()

at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)

at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

--- End of stack trace from previous location ---

at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)

at System.Windows.Threading.DispatcherOperation.Invoke()

at System.Windows.Threading.Dispatcher.ProcessQueue()

at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)

at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)

at System.Windows.Application.RunDispatcher(Object ignore)

at System.Windows.Application.RunInternal(Window window)

at DcmFolderScan.App.Main()

Developer technologies | C#
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 79,101 Reputation points Volunteer Moderator
    2025-07-30T18:09:00.0666667+00:00

    Not sure what you mean by run on”domain”. The error is pretty clear, the file access is denied. If h: is a network drive, then be sure it’s mounted under the user profile the app is running under.

    0 comments No comments

  2. Adiba Khan 245 Reputation points Microsoft External Staff
    2025-07-31T09:53:37.9166667+00:00

    Your app is trying to access a protected system folder:

    H:\System Volume Information- this is a restricted windows folder, and even administrators don’t have access to it by default.

    You can try these solutions:

    1.      Skip Restricted Paths in Code

    Update your code to skip or catch error when accessing restricted directories:

    Try

    {

                    Var files=Directory.GetFiles(path, «  *«, enumerationOptions) ;

                    //Continue processing files

    }

    Catch (UnauthorizedAccessException ex)  

    {

                    //Log or ignore the folder

    Console.WriteLine($ »Access denied to folder : {path} ») ;

     

    }

     

     

    You can also pre-check the folder name:

    If(!path.Contains(“System Volume Information”))

    {

                    //proceed to scan

    }

    2.      Run the app as administrator

    3.      Filter Input Paths

    If you’re allowing users to select drives or directories, avoid hidden/system folder unless explicitly needed. Use DirectoryInfo.Attributes to filter:

    Var dirInfo = new DirectoryInfo(path);

    If(!dirInfo.Attributes.HasFlag(FileAttributes.System))

    {

    //safe to scan

    }

     

    Hope this helps. Please try this and let me know for more query?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.