I have a dll built with latest c++.
There is a exported function get_pv_wrapper
that accepts a char* and returns a complex structure:
Value* reply = get_pv_wrapper("TEST:Model_RBV");
reply
cout print:
// Value - Generic data container. Structure changes based on input type
Value object:
struct "epics:nt/NTScalar:1.0" {
string value = "SoftIOC"
struct "alarm_t" {
int32_t severity = 0
int32_t status = 2
string message = "UDF"
} alarm
struct {
string description = ""
string units = ""
struct "enum_t" {
int32_t index = 0
string[] choices = {7}["Default", "String", "Binary", "Decimal", "Hex", "Exponential", "Engineering"]
} form
} display
}
Now I am trying to read this value in C# using P/Invoke but it fails as the struct contains std::string
fields.
Does anyone has any idea how I can read this object (using c#) without changing anything in the dll?
Also, writing a c++ wrapper is something I’m considering but as Value
class uses a generic templates, it may not be worth doing it.
Tried so far:
a) built a sample C# application to read the C++ object using P/Invoke. It works only with C types.
c) Write custom c# marshal but that only works with char *
b) Writing CLR program but it is not compatible with .NET7 (only works with .NET7-windows7)
I understand Interop only support C types, but is there a work around to achieve this?