gpt4 book ai didi

c# - 缺少装配引用

转载 作者:行者123 更新时间:2023-12-02 10:46:59 24 4
gpt4 key购买 nike

我使用 sgen 为“VcdcClassStructure.dll”中包含的唯一类生成了一个自定义类序列化程序。根据文档。现在的文件表明我需要做的就是

  • 添加对“VcdcClassStructure.dll”和 sgen 生成的“VcdcClassStructure.XmlSerializers.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命名空间的代码。 为什么编译器提示这些引用?

    谢谢你的时间。

    编辑。以证明我没有错过上述任何步骤。

    enter image description here

    最佳答案

    我已经检查过了,描述的过程可以正常工作。因此,我不得不假设您在步骤中犯了错误。它工作正常(注意:我在库中创建的类型是 SomeType ,因此得名):

    enter image description here

    您可能想再次尝试执行这些步骤。

    关于c# - 缺少装配引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18573218/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com