This snippet is a helloworld-like example illustrating the framework goal I am trying to achieve. The goal of this project is to control the GUI from a seperate piece of code in C# or VBA, e.g. an automation routine that talks to equipment and other pieces of software. The GUI is there for the benefit of the user not using automation, but I also want to automate pieces of the GUI as if someone were there
I am trying to link a GUI and a COM dll together as stated above without much success.
Both projects work separately.
I have verified I can call the COM dll functions.
I have also verified the simple GUI works.
Now I would like to have functions inside the GUI that are callable from the COM dll.
I thought it was as easy as adding the other project and adding a reference, but I am doing something wrong. It's funny because the code completion makes it seem as I am very close, as you can see from the screenshots.
GUI Project:
namespace GUI_HELLOWORLD
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void Button1_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello World.");
}
public void Button1_Click()
{
//For the sake of clicking through code - figure out correct method later
MessageBox.Show("Hello World.");
}
}
}
DLL project:
namespace GUI_COM_LIB
{
[System.Runtime.InteropServices.ComVisible(true)] //- may not be necessary in some cases?
public class ZZ_GUI_HELLOWORLD_API_DEMO
{
public void SelHello()
{
GUI_HELLOWORLD.MainWindow.Button1_Click(); // ERROR!
}
When adding a reference to the GUI into the COM_LIB dll project, I can see the GUI in the pop up menu, so it's seeing it's there! However when I type GUI_HELLOWORLD.MainWindow.
, no public functions come up where I would expect to see Button1_Click()