Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
DllImport and MarshalAs to interop, but considering maintainability, it will be a pain in the ass.
My suggestion is to load both projects as a single solution in visual studio, then use the magical managed mode for cpp. It's truly a whole other world when .net meets binaries, have fun! 😅 -
SomeNone7115yNot sure I understand… do you want to use functions/methods exported by the C++ app? If so, DllImport is your friend.
Or do you want to run the C++ app, potentially passing input to it, and return its output to the C# app? Spawn a process, attach TextReader objects as stdin/stdout/stderr, and use the usual .NET functionality to write to/read from them.
I'll leave investigating the details as an exercise to you. -
@SomeNone the second one is exactly what I want to do, however everything that I’ve read is telling me to reference the exe file rather than linking to a library, unless I’m missing something
@myss can I still pass command line arguments through to a DLL?
@HitWRight are you able to pass through a link to some documentation, I’ve not been able to find anything -
@err-occured by what you wrote to @SomeNone, that is what is suggested, add the project/exe as a reference.
https://docs.microsoft.com/en-us/...
The link is for DllImport. There are a lot of specifics on how dynamic linking works, would suggest to read on that also
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966931Difference between C# and Javascript Me: Hold my cup of tea. C#: That's not a cup of tea. Me: Hold my cup o...
I'm at a bit of a loose end here, I'll do my best to explain and I hope it all makes sense.
I'm trying to find a way to wrap a C++ Console App in a C# Class so I can use the C++ App as a library within the C# app rather than triggering the C++ exe and providing a command to it.
The reason why I wish to do it this way is for maintainability, so I can make changes to the C++ app without affecting the C# App.
I've been looking at tutorials and stack overflow to see if's its possible, but for someone with learning difficulties, I'm struggling to find the right path to take as I'm seeing conflicting info.
Any help would be greatly appreciated, Thanks in advance
question
cli wrapper
c#
c++