XmlSerializer

Giorgio Sfiligoi 186 Reputation points
2024-07-22T11:45:15.3133333+00:00

The debugger reports that the constructor of XmlSerializer throws System.IO.FileNotFoundException 2 times.

They are handled internally by the framework and the XmlSerializer seems to work fine.

May I safely ignore these exceptions?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,902 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 46,216 Reputation points Microsoft Vendor
    2024-07-22T12:25:14.7866667+00:00

    Hi @Giorgio Sfiligoi , Welcome to Microsoft Q&A,

    These exceptions are handled internally by XmlSerializer and do not usually affect its normal operation. In some cases, these exceptions are caused by XmlSerializer when it tries to dynamically generate serialization assemblies, which is part of the normal operation of XmlSerializer.

    In Visual Studio, you can configure the debugger to ignore these specific FileNotFoundException exceptions. This way, the debugger will not break when these exceptions are thrown.

    You can generate serialization assemblies ahead of time. This prevents XmlSerializer from dynamically generating these assemblies at runtime, which reduces the occurrence of exceptions.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.