我使用 sgen
为“VcdcClassStructure.dll”中包含的唯一类生成了一个自定义类序列化程序。根据文档。现在的文件表明我需要做的就是
使用 VcdcClassStructure;
使用 Microsoft.Xml.Serialization.GeneratedAssembly;`
(我已经使用 DotPeek 确认命名空间是正确的)。
然后我改变了我的代码
XmlSerializer serializer = new XmlSerializer(typeof(message));
serializer.Serialize(writer, vcdMsg);
到
messageSerializer serializer = new messageSerializer();
serializer.Serialize(writer, vcdMsg);
但是在编译时我得到了
The type or namespace name 'VcdcClassStructure' could not be found (are you missing a using directive or an assembly reference?)
和
The type or namespace name 'Xml' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
我引用了相关程序集并添加了
using
命名空间的代码。 为什么编译器提示这些引用? 谢谢你的时间。
编辑。以证明我没有错过上述任何步骤。
最佳答案
我已经检查过了,描述的过程可以正常工作。因此,我不得不假设您在步骤中犯了错误。它工作正常(注意:我在库中创建的类型是 SomeType
,因此得名):
您可能想再次尝试执行这些步骤。
关于c# - 缺少装配引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18573218/