所以我正在读一本书"由亚当纳森释放的wpf4"并看到了一个关于"在WPF窗口中托管终端服务ActiveX控件的示例"。它显示了一些代码,我发现我应该这样做。
using System;
using System.Windows;
using System.Windows.Forms.Integration;
namespace HostingActiveX
{
public partial class Window1 : Window
{
AxMSTSCLib.AxMsTscAxNotSafeForScripting termServ;
public Window1()
{
InitializeComponent();
// Create the host and the ActiveX control
WindowsFormsHost host = new WindowsFormsHost();
termServ = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();
// Add the ActiveX control to the host, and the host to the WPF panel
host.Child = termServ;
panel.Children.Add(host);
}
void connectButton_Click(object sender, RoutedEventArgs e)
{
termServ.Server = serverBox.Text;
termServ.Connect();
}
}
}
和XAML:
<Window x:Class=”HostingActiveX.Window1”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Hosting the Terminal Services ActiveX Control”>
<DockPanel Name=”panel” Margin=”10”>
<StackPanel Margin=”0,0,0,10” DockPanel.Dock=”Top” Orientation=”Horizontal”>
<TextBox x:Name=”serverBox” Width=”180” Margin=”0,0,10,0”/>
<Button x:Name=”connectButton” Click=”connectButton_Click”>Connect</Button>
</StackPanel>
</DockPanel>
</Window>
但我无法找到AxMSTSCLib的参考资料。我添加了MSTSCLib,但它不喜欢它。我在哪里可以找到AxMSTSCLib?