I have one .Net assembly which includes native .h files as a link. The .h file is placed at a common loaction and used across projects (C++ and C#).
These header files have some structures and #define in it.
In my .Net assembly i have defined structures and doing marshalling using Interop services and is working fine. For #define also, i defined
variables in .Net assembly and setting the value, something like:
C++ .h file
#define MyValue 0x100
internal class MyClass
protected const MyValue = 0x100;
But with such code, i need to update MyValue in C# assembly everytime it gets modified in .h file. And generally in my project, the
structures in this .h file are not changed but the #define variable gets modified often.
Is there any way, that allows me
to set this variable directly from .h file, something like:
Is using COM an option here? You are basically manually doing what COM can do for you by exposing types and structures defined in the native dll (#defines will still be an issue though). If you can't go the COM route then yes, you will need to parse the files when they change, preferably in an automated fashion as MadHatter suggested.