0

The problem I have is that when running my program outside of Visual Studio, this error message gets thrown and pops up as an error shown to my users. This is only happening on one computer (Windows Server 2016). According to this question this exception is supposed to be thrown and handled internally by XmlSerializer. This is not being run in Visual Studio, so the option to debug just my code doesn't apply. Unfortunately, Google is only turning up answers where this exception was intercepted during debugging with Visual Studio, which doesn't help me. I realize that there is a "generate serialization assembly" option in each VS project that I could change from auto. My problem with that solution is that I don't want to have a custom build just for this client, especially when no one else suffers this problem.

2021-08-27 Update with more information

What is the problem?

Why is the error "Could not load file or assembly 'MyAssembly.XmlSerializers'" being thrown by the .NET Framework (v4.7.2 specifically) and propagating out to my code in production, when this should be handled internally by the .NET Framework?

What debugging have I done?

  • Tested the software in a clean Windows Server 2016 virtual machine - no issue there
  • Generated the XMlSerializers.dll files using sgen.exe, this removes the error message, but doesn't explain why the .NET Framework did not handle these missing files as it should. Its a Band-Aid without understanding the underlying problem.
  • Lots of Googling to find any source of this error, but the search results only apply if the code is being debugged inside Visual Studio, which it isn't in this case.
Tieson T.
  • 20,774
  • 6
  • 77
  • 92
chippies
  • 1,595
  • 10
  • 20
  • Probably a dumb question, but is this code being run in an environment where the process is allowed to write files to disk? Can't say that I've used run into serialization problems like this, but if I read the linked answer correctly, it sounds like your code needs to generate a dll if it's missing, and perhaps it's failing to do so, if the process only has read & execute permissions. – Tieson T. Aug 27 '21 at 09:17
  • 1
    The environment definitely has some things locked down. I granted the user account read/write/modify permissions to the folder where it runs and all its files are stored (including subfolders/files), as well as making it the owner of that folder and subfolders/files. That didn't help unfortunately. You may be on to something though, looks like the .NET Framework is supposed generate temporary DLLs for these XMLSerializers.dll files. The temp files folder shouldn't' be locked by default AFAIK, but maybe that's the problem. – chippies Aug 28 '21 at 13:06
  • I suppose one wild-really-shouldn't-do-this test would be run the executable with elevated privileges - if the error doesn't occur when running as an administrator, that might reinforce the thinking that it's a permissions issue that the serializer doesn't account for. Another really-shouldn't-be-the-problem thought is to verify that whatever antivirus is running on the server isn't flagging a newly-generated dll as untrusted and removing it. That might be a question for ServerFault, though. – Tieson T. Aug 29 '21 at 06:24
  • I tried running it with elevated privileges, but that didn't help. The antivirus is just Windows Defender, but I'll investigate. – chippies Aug 30 '21 at 07:20

0 Answers0