未找到反序列化‘DataDynamics.BarCode.BarEngine+BarEngineException’类型对象的构造函数

      在公司的项目中(项目用到了remoting),利用ActiveReport控件做打印,其中用到了BarCode这个控件,条形码格式选择的是EAN-13。在客户端打印预览时,抛出了异常:

      “未找到反序列化‘DataDynamics.BarCode.BarEngine+BarEngineException’类型对象的构造函数”

      经过追踪,服务端抛出的异常是在

" at DataDynamics.ActiveReports.Barcode.#Pvb(GraphicsCache cache, Page page, PointF pageOffset, Single startPos, Single endPos)/r/n  

at DataDynamics.ActiveReports.ARControl.Render(GraphicsCache gRef, Page page, PointF pageOffset, Single startPos, Single endPos)/r/n  

at DataDynamics.ActiveReports.Section.Render(GraphicsCache cache, Page page, PointF pageOffset, Single pageWidth, Single drawStartPos, Single drawEndPos)/r/n  

at #mb.#mqb.#vDb()/r/n   at #mb.#vqb.#rEb()/r/n  

at #mb.#vqb.#qEb(Page newPage, Single left, Single top, Single right, Single bottom, UInt32 flags, UInt32& status)/r/n  

at DataDynamics.ActiveReports.ActiveReport3.#4yb()/r/n  

at DataDynamics.ActiveReports.ActiveReport3.Run(Boolean syncDocument)/r/n  

at DataDynamics.ActiveReports.ActiveReport3.Run()/r/n "

方法内,抛出的错误信息: ‘incorrect data length’。

      后来查到是由于BarCode这个控件赋的值不符合条形码EAN-13的规范,后来改成EAN-13标准的13码,问题解决了。

``` class TestData : public QObject { Q_OBJECT public: TestData(QObject *parent = nullptr) : QObject(parent) {} //关键 必须这么写 TestData(const TestData &other) : QObject(other.parent()) { //this = other; // Copy other data members here this->Barcode = other.Barcode; this->CameraCounts = other.CameraCounts; this->GroupDefine = other.GroupDefine; this->Basic = other.Basic; this->Result = other.Result; this->Normal = other.Normal; this->Defocus = other.Defocus; this->m_bBarcode = other.m_bBarcode; this->m_bCameraCounts = other.m_bCameraCounts; this->m_bDefocus = other.m_bDefocus; this->m_bGroupDefine = other.m_bGroupDefine; } //Person &operator=(const Person &other) = delete; // 禁用赋值运算符 //关键 必须这么写 TestData &operator=(const TestData &other) { if (this != &other) { //this = other; // Copy other data members here this->Barcode = other.Barcode; this->CameraCounts = other.CameraCounts; this->GroupDefine = other.GroupDefine; this->Basic = other.Basic; this->Result = other.Result; this->Normal = other.Normal; this->Defocus = other.Defocus; this->m_bBarcode = other.m_bBarcode; this->m_bCameraCounts = other.m_bCameraCounts; this->m_bDefocus = other.m_bDefocus; this->m_bGroupDefine = other.m_bGroupDefine; } return *this; } public: QString Barcode; QString CameraCounts; QVector<QString> GroupDefine; BasicData Basic; ResultData Result; NormalData Normal; DefocusData Defocus; bool m_bBarcode; bool m_bCameraCounts; bool m_bGroupDefine; bool m_bDefocus; public: QVariantMap toVariantMap() const { QVariantMap map; if (m_bBarcode) { map["Barcode"] = QVariant::fromValue(Barcode); } if (m_bCameraCounts) { map["CameraCounts"] = QVariant::fromValue(CameraCounts); } if (m_bGroupDefine) { QVariantList list; for (auto item : GroupDefine) { list.append(item); } map["GroupDefine"] = list; } if (m_bDefocus) { QVariantMap tempDefocusMap = Defocus.toVariantMap(); if (tempDefocusMap.size() > 0) { map["Defocus"] = tempDefocusMap; } } QVariantMap tempBasicMap = Basic.toVariantMap(); if (tempBasicMap.size()>0) { map["Basic"] = tempBasicMap; } QVariantMap tempNormalMap = Normal.toVariantMap(); if (tempNormalMap.size() > 0) { map["Normal"] = tempNormalMap; } QVariantMap tempResultMap = Result.toVariantMap(); if (tempResultMap.size() > 0) { map["Result"] = tempResultMap; }```改用MFC+C++
03-22
``` class tagMTFTesterResult { public: string Final; // 最终结果 string MTF; // MTF结果 string DOF; // DOF结果 string FocalShift; // 场曲结果 string Astigmatism; // 像散结果 string FOV; // FOV结果 tagMTFTesterResultAverage Average; // 均值管控测试结果 string Aggregate; // 综合结果 string MultiFrqMTF; // 辅助频率结果 string Fail_Reason; // 失败原因 map<string, variant> toVariantMap() const { map<string, variant> resultMap; // 使用结构化绑定提升可读性(C++17) resultMap = { {"Final", Final}, {"MTF", MTF}, {"DOF", DOF}, {"FocalShift", FocalShift}, {"Astigmatism", Astigmatism}, {"FOV", FOV}, {"Aggregate", Aggregate}, {"MultiFrqMTF", MultiFrqMTF}, {"Fail Reason", Fail_Reason}, {"Average", Average.toVariantMap()} // 要求子结构体实现相同接口 }; return resultMap; } }; class TestData: public CObject { DECLARE_SERIAL(TestData) // 启用序列化 public: TestData() = default; // 默认构造函数 // 拷贝构造函数 TestData(const TestData& other) { CopyMembers(other); } // 赋值运算符 TestData& operator=(const TestData& other) { if (this != &other) { CopyMembers(other); } return *this; } public: // 成员变量 std::string Barcode; std::string CameraCounts; std::vector<string> GroupDefine; tagMTFTesterResult result; public: // 序列化方法(返回std::map替代QVariantMap) map<string, variant> toVariantMap() const { } TestData fromVariant(variant) {} private: // 辅助函数:深拷贝成员变量 void CopyMembers(const TestData& other) { result = other.result; } };```map<string, variant>报错
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值