Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
创建可供VB使用的C#WPF DLL_C#_Wpf_Vb.net_User Interface_Dll - Fatal编程技术网

创建可供VB使用的C#WPF DLL

创建可供VB使用的C#WPF DLL,c#,wpf,vb.net,user-interface,dll,C#,Wpf,Vb.net,User Interface,Dll,我尝试用WPF框架在C#中创建一个DLL。我想在VB(excel)中使用这个DLL作为GUI。我在VisualStudio上开发了我的DLL,并创建了一个UserControl WPF库项目 目标是使用WPF在C#DLL中创建GUI界面,并在我的Visual Basic脚本中使用它。例如:我想用WPF/C#创建两个按钮,创建一个包含我的两个按钮的DLL。然后,在我的Visual Basic窗口中显示它们 我创建了一个UserControl WPF项目,并在此UserControl中放置了两个按钮

我尝试用WPF框架在C#中创建一个DLL。我想在VB(excel)中使用这个DLL作为GUI。我在VisualStudio上开发了我的DLL,并创建了一个UserControl WPF库项目

目标是使用WPF在C#DLL中创建GUI界面,并在我的Visual Basic脚本中使用它。例如:我想用WPF/C#创建两个按钮,创建一个包含我的两个按钮的DLL。然后,在我的Visual Basic窗口中显示它们

我创建了一个UserControl WPF项目,并在此UserControl中放置了两个按钮。 请参阅我的xaml代码:

我的C#类:

我的DLL构建成功了。 然后,我运行以下命令来注册我的DLL:

regasm /codebase /s WpfControlLibrary1.dll

但是在这些步骤之后,我在VB中看不到我的DLL的引用。我无法在WpfControlLibrary1类型的对象上创建

所以我的问题是…如何创建一个带有GUI WPF的C#DLL,它可以显示在VisualBasicGUI中? 我应该在VisualStudio中创建UserControl WPF项目吗? 还有其他解决办法吗

一个没有WPF的简单C#DLL在VB中运行良好,但我不知道如何使用WPF GUI


谢谢你的帮助;)

不确定UserControlLibrary项目。然而,我以前也遇到过类似的情况,我不得不从事一个已经在Vb.net中开发的项目。因此,我们在C#中开发新控件,并在Vb.net中引用它们

  • 创建类库
  • 添加引用:System.xaml、Presentationcore、System.drawing
  • 向解决方案添加新的UserControl项
  • 在此阶段之后,您可以根据自己的意愿修改用户控件。打开新的/现有的Vb.net项目并添加此.dll(从C#创建,包含usercontrol)作为引用

  • 在Xaml内部,添加对名称空间的引用并使用相同的名称空间


  • “我无法在WpfControlLibrary1类型的对象上创建”。WpfControlLibrary1是一个命名空间。它不能有instancesYes,但也不能创建UserControl1对象,无论如何,我不能添加对VB1的引用。这并不能解决这个问题,即创建可以从Excel使用的UI库。