Actually the question is, the implementation of GetObjectData is there, but it gives a warning. I suppose that the format of the GetObjectData declaration does not match, but I took the format from MSDN.
Class Code:
[Serializable] public ref struct EmuDevException : public Exception, ISerializable { private: int __line; String ^ __msg; GameData::EmuDevError __id; System::Exception ^ __ex; protected: EmuDevException::EmuDevException( SerializationInfo ^info, StreamingContext ^context) { if (info == nullptr) return; this->Id = (GameData::EmuDevError)(info->GetByte(L"Id")); this->Line = info->GetInt32(L"Line"); this->Msg = info->GetString(L"Msg"); } public: property String ^ Msg { String ^ get() { return __msg; } void set(String ^v) { __msg = v; } }; property GameData::EmuDevError Id { GameData::EmuDevError get() { return __id; } void set(GameData::EmuDevError v) { __id = v; } }; property int Line { int get() { return __line; } void set(int v) { __line = v; } }; property System::Exception ^ InnerExcept { System::Exception ^ get() { return __ex; } }; [System::Security::Permissions::SecurityPermission( System::Security::Permissions::SecurityAction::LinkDemand, Flags = System::Security::Permissions::SecurityPermissionFlag::SerializationFormatter, Unrestricted = false )] void GetObjectData( SerializationInfo ^info, StreamingContext ^context) { if (info == nullptr) return; info->AddValue(L"Id", __id); info->AddValue(L"Line", __line); info->AddValue(L"Msg", __msg); } EmuDevException::EmuDevException(GameData::EmuDevError _id) : __id(_id), __line(-1), __msg(String::Empty), __ex(nullptr) {} EmuDevException::EmuDevException(GameData::EmuDevError _id, int _line) : __id(_id), __line(_line), __msg(String::Empty), __ex(nullptr) {} EmuDevException::EmuDevException(GameData::EmuDevError _id, int _line, String ^_msg) : __id(_id), __line(_line), __msg(_msg), __ex(nullptr) {} EmuDevException::EmuDevException(GameData::EmuDevError _id, int _line, System::Exception ^_ex) : __id(_id), __line(_line), __msg(String::Empty), __ex(_ex) {} }; Full error output:
MSBUILD: warning CA2240: Microsoft.Usage: Add the GetObjectData implementation to the 'EmuDevException' type.
void virtual GetObjectData(SerializationInfo^ info, StreamingContext context) override- NewView