Monday, August 27, 2012

Is there any class similar to Silverlight's AutomationFactory for .NET?

Is there any class similar to Silverlight's AutomationFactory for .NET?

I found the class AutomationFactory in Silverlight, that is really usefull when you want to subscribe to an event using COM objects:

AutomationEvent quitEvent = AutomationFactory.GetEvent(word,"Quit"); quitEvent.EventRaised += new EventHandler<AutomationEventArgs>(quitEvent_EventRaised); 
  • Do you know any similar class that could be used from .NET?
  • Do you know the way to bind events using automation?

Thanks in advance.

Answers & Comments...

Answer: 1

I was pretty sure there was one, so after a bit of searching I found the list for .Net 4.0 and it includes System.Windows.Automation; IIRC that should be the one Silverlight's AutomationFactory was based off of. System.Windows.Automation

by : Az Zahttp://stackoverflow.com/users/1518265

Answer: 2

Seems it no AutomationFactory analog in .Net 4.0 But you can archive it by using System.Type:

 var type = Type.GetTypeFromProgID("Excel.Application");    var obj = Activator.CreateInstance(type);   obj.InvokeMember("Visible", BindingFlags.SetProperty, null, obj, parameter);  
by : devihttp://stackoverflow.com/users/451495




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog