In an effort to resolve this problem, I've found many posts that explain this behavior is actually expected. However, I've also found 'Using Microsoft XML Serializer Generator on .NET Core' which provides the steps to generate an associated 'serializer' dll alongside the target dll. Using these steps, I was able to build the XmlSerializer dll, but, it still throws an exception stating it cannot find the dll even though it's in the same folder as the associated target dll.
I'm using the following code to serialize the class.
try
{
XmlSerializer serializer = new XmlSerializer(typeof(Rss));
// Create an XmlTextWriter using a FileStream.
fs = new FileStream(_feedpath, FileMode.Create);
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
settings.Indent = true;
settings.DoNotEscapeUriAttributes = false;
writer = XmlWriter.Create(fs, settings);
// Serialize using the XmlTextWriter.
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
serializer.Serialize(writer, mrss, ns);
writer.Close();
fs.Close();
originalMrss = mrss.Clone();
}
catch (FileNotFoundException excp)
{
// Trap the XmlSerializer not found message.
if (!excp.Message.Contains("XmlSerializer"))
success = false;
}
When the code throws the exception, nothing is written out to the XML file.
My true goal is to serialize a class to XML. I haven't been able to find a way to do this without encountering the above error.