i have a CLR class which uses the Attribute StructLayout attribte:
[StructLayout(LayoutKind::Explicit)]
public ref class Matrix4 : System::ComponentModel::INotifyPropertyChanged
All fields make use of the FieldOffset attribute. Now i need to add an event, in particular i want to implment the INotifyPropertyChanged interface and hence i need the
[FieldOffset(16*sizeof(Real))]
virtual event System::ComponentModel::PropertyChangedEventHandler^ PropertyChanged;
event. The compiler tells me I need to assign the FieldOffset attribute to this event, but after doing that the compiler throws the error message:
Error 34 error C1093: API call 'DefineCustomAttribute' failed '0x801311c0'
I am not allowed to chage StructLayout to Sequential so how do i solve this issue?
Any help would be appreciated,
Best, apo.
SOLVED by separating:
protected:
[field:FieldOffset(16*sizeof(Real))]
System::ComponentModel::PropertyChangedEventHandler^ _pc;
public:
virtual event System::ComponentModel::PropertyChangedEventHandler^ PropertyChanged
{
void add(System::ComponentModel::PropertyChangedEventHandler^ p)
{
_pc += p;
}
void remove(System::ComponentModel::PropertyChangedEventHandler^ p)
{
_pc -= p;
}
void raise(Object ^sender, System::ComponentModel::PropertyChangedEventArgs ^ args)
{
_pc->Invoke(sender, args);
}
};
void OnPropertyChanged(String^ info)
{
PropertyChanged(this, gcnew System::ComponentModel::PropertyChangedEventArgs(info));
}