.net - linking c# gui project and library dll project -
this snippet helloworld-like illustration illustrating framework goal trying achieve. goal of project command gui seperate piece of code in c# or vba, e.g. automation routine talks equipment , other pieces of software. gui there benefit of user not using automation, want automate pieces of gui if there
i trying link gui , com dll stated above without much success.
both projects work separately.
i have verified can phone call com dll functions.
i have verified simple gui works.
now have functions within gui callable com dll.
i thought easy adding other project , adding reference, doing wrong. it's funny because code completion makes seem close, can see 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 sake of clicking through code - figure out right method later messagebox.show("hello world."); } } }
dll project:
namespace gui_com_lib { [system.runtime.interopservices.comvisible(true)] //- may not necessary in cases? public class zz_gui_helloworld_api_demo { public void selhello() { gui_helloworld.mainwindow.button1_click(); // error! }
when adding reference gui com_lib dll project, can see gui in pop menu, it's seeing it's there! when type gui_helloworld.mainwindow.
, no public functions come expect see button1_click()
you need instance of window object:
public void selhello() { var mywindow = new gui_helloworld.mainwindow(); mywindow.button1_click(); }
c# .net visual-studio user-interface
No comments:
Post a Comment