views:

25

answers:

1

I've written an ATL/ActiveX object which exposes various properties and methods through its COM interface. I'd like to be able to access those methods and properties from a Silverlight application. The problem I'm running into is that I can access the methods from Silverlight/C#, but I haven't figured out the right syntax for accessing its properties.

In other words, my Silverlight C# code looks something like this:

var ax = HtmlPage.Document.CreateElement("object");
ax.Id = "myControl";
ax.SetAttribute("style", "width: 1px; height: 1px;");
ax.SetAttribute("classid", "CLSID:42832F4C-3480-4450-A6B5-156B2EFC408F");
HtmlPage.Document.Body.AppendChild(ax);

// This works
ax.Invoke("SomeMethod", "param1", "param2");

// Each of these throw a "Failed to invoke" InvalidOperationException
ax.Invoke("SomeProperty");
ax.Invoke("SomeProperty", "propertyValue");
ax.Invoke("get_SomeProperty");
ax.Invoke("put_SomeProperty", "propertyValue");

I could, of course, write a pure JavaScript wrapper around the AX object, and invoke the JavaScript functions from Silverlight, and I may yet do so. But I'd prefer to avoid writing and maintaining that separate layer if I don't have to.

Any suggestions?

A: 

OK, the solution was obvious, I just hadn't looked hard enough. The correct syntax is:

ax.GetProperty("SomeProperty");
ax.SetProperty("SomeProperty", "propertyValue");

Duh.

Ken Smith