Exception caught by try/catch block but .Net still crash the application

iz111 86 Reputation points
2022-07-07T07:10:38.98+00:00

The msrdc.exe (Azure RDP client) is loading my .NET addin but it has some issues with try/catch exception.

For example if I try to delete file or directory that is not exist .Net will caught exception but application will still crash.
Same happens with other exceptions, for example object not referenced. This happens in some Windows 10/11 (x64) machines but only with msrdc.exe x64.
Other .Net applications catch exception but does not crash.

Faulting application name: msrdc.exe, version: 1.2.3004.0, time stamp: 0x623e5b83  
Faulting module name: ntdll.dll, version: 10.0.19041.1566, time stamp: 0x1be73aa8  
Exception code: 0xc0000409  
Fault offset: 0x00000000000a1251  
Faulting process id: 0x4d90  

Example code that crash the application:

try  
{  
   File.Delete(filePath);  
}  
catch (Exception ex)  
{  }  

What could cause this behavior? Is there some configuration that I am missing?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,873 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,195 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,141 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,989 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,511 Reputation points
    2022-07-11T14:24:40.047+00:00

    Hi Iz.

    Thank you for posting your query.

    Kindly try the solution provided below.

    Solution 1. Run System File Checker
    As we have mentioned in the above part, the exception code: 0xc0000409 may be caused by the corrupted system files.

    So, in order to fix the error, you can run System File Checker to scan and fix the corrupted system files.

    Step 1: Type Command Prompt in the search box of Windows and choose the best-matched one. Then right-click it to choose Run as administrator to continue.

    Step 2: In the command line window, type the command sfc /scannow and hit Enter to continue.

    Solution 2. Perform a Clean Boot
    In order to fix the error code 0xc0000409, you can try performing a clean boot.

    Now, we will show you the detailed tutorial.

    Step 1: Press Windows key and R key together to open Run dialog, then type msconfig in the box and click OK to continue.

    Step 2: In the pop-up window, go to the Service tab and check the option Hide all Microsoft services. Then click Disable all to continue.

    Step 3: Then navigate to the Startup tab and click Open Task Manager to continue.

    Step 4: In the Task Manager window, select the startup program you do not need and click Disable.

    When it is finished, reboot your computer.

    Solution 3. Reinstall the Application
    To fix the unknown software exception 0xc0000409 error, you can choose to reinstall the application.

    Thus, you can go to the Control Panel to uninstall the software first, then go to the official website to download it again. After that, launch the application again and check whether the error code: 0xc0000409 is solved.

    Solution 4. Perform System Restore
    There is an available solution for you. The solution can only be applied when you have created a system restore point before. If you don’t have the restore point, you can apply the above solutions.

    --------------------------------------------------------------------------------------------------------------------------------------

    If the answer is helpful kindly click "Accept as answer" and upvote it. Thanks.


  2. Afamefuna 1 Reputation point
    2022-07-14T09:27:29.067+00:00

    From your description it appears you have narrowed it down to system API Library unique to msrdc.exe x64. You went further and described the reason given as object not referenced.

    Object not referenced imply that your code is coursing a memory access violation I came to this conclusion because of the resultant action taken by the OS. Memory access violation can cripple the OS therefore that system library module unique to msrdc.exe x64 closes down the application that is coursing the memory access violation.

    Now why does it happen only on with msrdc.exe x64 I would suggest because the system API for that particular package handles memory access violation differently.

    Note, every system module has supporting system API powering it and this system API can sometimes behave in a manner different from others because of human factor.

    What work around do I suggest? maybe adding a extra line or two of code within the try statement to check that the item you wish to delete exist if it does then delete it if it does not then ...

    Hope this helps, software development can be a nightmare especially when your work relies on hundreds of system libraries and external contributor libraries.

    Hope this helps

    0 comments No comments