Click here to Skip to main content
15,885,754 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
C#
[Guid("830EE869-B8B4-4f41-870D-79BB7724D492"), ComVisible(true)]
  public partial class UserControl1 : UserControl
  {
      public UserControl1()
      {
          InitializeComponent();
      }

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

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;
Posted
Updated 30-Jan-12 21:04pm
v2

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.
 
Share this answer
 
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[^]
 
Share this answer
 
Comments
striving_zhou 31-Jan-12 3:12am    
thanks for your reply, my application use some geomety API which not exist in silverlight, so change into silverlight application need some work and i'm doing this now. with the winform host wpf can indeed do same work, but it like a middle layer not concise enough.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900