I really haven”t looked at any Silverlight code for at least 2 months. In fact, I haven”t really been around the forums until today. Now that I”ve returned :,,), I”ve noticed that there”s a lot of similar questions around sharing code between .NET and the “mini-CLR” that is used Silverlight.
The first thing you should notice is that you cannot pass .NET components to Silverlight methods! Don”t even try this 🙂 Even though I haven”t looked at it for more than 2 months I”m almost positivethat you cannot even interop with ActiveX controls without going through JS code!
What you can do is “share” code so that you can build a class and then use that class from your Silverlight code and from other .NET code. Don”t worry: this is a short post 🙂 Instead of giving you several pieces of advice, I”ll just redirect you to a great article by Daniel Moth:
Don”t let the title fool you! Even though Daniel has written it thinking about mobile apps, the concepts do apply to code that needs to be shared by SL and other kind of .NET apps. Btw, if you”re not subscribed to Daniel”s most excellent blog, then here”s the RSS feed for it. There are really lots of cool posts over there!