为什么调用控件类没有引用
程序代码:
public partial class UserControlOne : UserControl { private Class1 pmclass; private bool Open; public PowerMILL.Application TestMain; //PowerMILL.Application这是接口 public UserControlOne(Class1 class1, bool open) { InitializeComponent(); this.Open = open; if (open) { this.pmclass = class1; } else { try { TestMain = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerMILL.Application") as PowerMILL.Application; } catch(Exception) { MessageBox.Show("链接失败"); } } } private void COM(string comstr) { if (Open) { pmclass.Services.InsertCommand(pmclass.Token, comstr); Pmevenlist(); } else { MessageBox.Show(comstr); this.TestMain.DoCommand(comstr); } }
程序代码:
[local]1[/local]public partial class TestMain : Window { public TestMain() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { UserControlOne app = new UserControlOne(null,false); gridOne.Children.Add(app); } } }
[此贴子已经被作者于2021-9-23 21:16编辑过]