Hi guys I really need your help. Im developing a C# app thats going to be home to a few plugins. So Im writing the first dll and already in trouble (don't do much c# mainly c++).
anyways so far i have a class within my dll that takes a param of type object this is sent from my main exe. i send a user defined struct as type object and when i try to cast it back on the other side i get a 'Specified cast is not valid' exception. any ideas on how i can send a user defined struct from one side to the other????????

Is there a reason why you have to set up the methods to take a type of "Object"? Will your "main" program accept DLLs that pass structs/classes of many types? Even if that's the case, your main project will still have to know about them in order to cast the inbound class/structs to the correct type (assuming you weren't getting that error).

Can you set up the main program so that when it loads the DLL, the methods pass structs/classes via method signatures that are known to both the DLL and main?

I know I'm generalizing, but other than your statement, I don't know the overall design goal of your program & libraries.

Yeah it can that was my previous design but i want to try and pack up all these structs/classes into one user defined struct and send it across to my DLL. the only reason i have my dll accepting a param of type object is because the getconstructor() method would fail otherwise. wow its so much easier in c++ lol. I guess i can revert to my previous design. it wouldve bn nice to send it all in one struct.

This article has been dead for over six months. Start a new discussion instead.