WPF Application as dll to use in C++ code (another dll)

radu01

New member
Joined
Oct 14, 2023
Messages
3
Programming Experience
Beginner
Good evening! I would like to make an application in WPF C# in which to expose some methods: open the window, close the window, select text. I want to call this application from C++, so it must be of dll type. At the end of the practical project from a dll written in C++ I will call these methods from the previously explained C# dll. Is there any option for this? I tried several methods but I came to the conclusion that I need an .exe to initialize the internal structures for the GUI.
 
In your C++ code, you would need to host the CLR. I('m quite sure there is documentation somewhere on how to host the CLR otherwise MS will get back into DOJ trouble for going back on the consent decree.) Once you have hosted the CLR, you can then load that assembly (what you are calling a DLL) into the app domain that is in the hosted CLR.
 
Yes, I tried that but I have that error. I found some solutions but doesn't work.
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b33b2f7e11f51b4a' or one of its dependencies. The system cannot find the file specified.'
 
Yup, you'll need to also need all the other upstream dependencies of your assembly.
 
There is a tutorial or something else on how to resolve that dependencies? I didn't found something on this..
 
If you use dotPeek or some other IL disassembler, they should the assemblies referenced by a particular assembly. Recursively inspect the assemblies.
 
First let us determine if another design would work better. If possible, it would be better to have a WPF application that calls a C++ CLR Class Library. The Class Library can be called from the C# WPF application the same as if the Class Library was written in C#. If that design can satisfy requirements then it would be easier.
 
Back
Top Bottom