I already had to deal with such different sizes of the same class.
This leads at best to crashes (since your code will try to read / write outside the actual class data), and in the worst case, to strange errors (for example, set the value of a member variable to 42 and, when reading, see the value instead 1376256 or something like that.)
The reason was usually related to alignment problems.
here what you can do to find out if your problem is an alignment problem:
Before defining a class (or after) add the following line:
#pragma pack(show)
In the compilation output, you should see something like:
1>. \ Test_align.cpp (59): warning C4810: pragma pack (show) value == 8
This will show alignment when compiling the header. This will be displayed every time the header is included in the CPP file. This value should always be the same, both in compiling a DLL and in compiling an EXE.
If they are different, even once, then you have a problem with incorrect alignment ...
Default Struct Alignement for the project?
Perhaps your DLL has a default alignment of 1 by default, while the EXE has a different value. Please check the properties of both projects: Section "C / C ++", subsection "Generation of code", property "member alignment Struct".
For everything to work correctly, both projects must have the same value.
If the EXE and the DLL have different values, you should fix this (the default value is usually used: select "inherit from parent or project value").
Pragma package?
There is another way to break the alignment, i.e. using the #pragma pack statements. For instance:
#pragma pack(show)
So, find the #pragma pack statements and make sure that they are always correctly installed and not set (if you have a click without a pop file, you may have an error).
Does the class have the same alignment for both projects?
If you did not find a problem in your class, perhaps the problem is that in one of the / struct classes that it inherits from or has as a member variable.
So check them out the same way you checked the main class.