我可以为ActiveX制作WPF应用程序吗 [英] can i make a wpf application for activex

查看:65
本文介绍了我可以为ActiveX制作WPF应用程序吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于winform应用程序可以制作成activex,因此可以在webform中使用,如果我不想将wpf应用程序转换成silverlight应用程序,我可以将它转换成activex吗,我试过了,但是它不能像winform那样做,有人可以给一些吗?帮助吗?

更多信息:
使用winform,我创建了一个用户控件

as winform application can make into activex, so it can use in webform, can i make wpf application into activex if i donot want to tranlate it into silverlight application, i tried, but it cannot do as winform, can anybody gave some help?

more info:
with winform, i create a usercontrol

[Guid("830EE869-B8B4-4f41-870D-79BB7724D492"), ComVisible(true)]
  public partial class UserControl1 : UserControl
  {
      public UserControl1()
      {
          InitializeComponent();
      }

      public void ShowMessage()
      {
          MessageBox.Show("Hello World!");
      }
  }


并使用obj = new ActiveXObject("WinformActiveX.UserControl1");创建对象,调用obj.ShowMessage()没问题;
但是使用wpf时,调用obj.ShowMessage()方法时有一个空引用;


and use obj = new ActiveXObject("WinformActiveX.UserControl1"); to create the object, there is no problem to call obj.ShowMessage();
but with wpf, there is a nullreference when call the obj.ShowMessage() method;

推荐答案

我认为您可以做到这一点.当然,您的最终用户需要安装正确的.NET版本,但是如果您使用的是.NET,则始终会这样做,因此这不会改变.我认为改用Silverlight是更好的选择,但我认为没有任何真正的理由不起作用.您的问题非常模糊,但是,也许您需要具体告诉我们您遇到的问题.如果是我,我将使用最基本的WPF窗口创建一个activeX控件并对其进行测试,以确保问题与执行此操作有关,而不与所添加代码的细节有关.
I would assume you can do this. Of course, your end user needs the right .NET version installed, but they always would if you''re using .NET, so that should not change. I would think that moving to silverlight is a better option, but I don''t see any real reason for this not to work. Your question is very vague, however, perhaps you need to specifically tell us what issue you''re having. If this was me, I''d be creating an activeX control using the most basic WPF window and testing that, to make sure the issue is related to doing that, and not the specifics of the code you''re adding.


此处关于WPF作为Activex的争论很少:

http://social.msdn.microsoft.com/Forums/zh/wpf/thread/031007cf-2812-43e7-a8e4-ee03d9048c45 [ http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf- in-winforms [ ^ ]
There are few arguments about WPF as Activex here:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/031007cf-2812-43e7-a8e4-ee03d9048c45[^]

And coming to the point of consuming WPF in Webforms the content in this link may guide you:

http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms[^]


这篇关于我可以为ActiveX制作WPF应用程序吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆