开发者

Expose C# classes in .net 4 class library to Silverlight App

开发者 https://www.devze.com 2023-03-09 17:27 出处:网络
I have a bunch of classes in a C# class library that I bought from a 3rd party company. I want to use these classes and create my classes by inheriting them.

I have a bunch of classes in a C# class library that I bought from a 3rd party company.

I want to use these classes and create my classes by inheriting them. I have it all working on a .net 4 wpf application.

I want to then use these classes in my silverlight application.

What options do I have and which is the best option? I want to use it in such a way that I can update the 3rd party company's DLL as they release their new version every month.

Just to re-inforce few poi开发者_开发问答nts:

We have few options. 1. Link the classes (as an adding existing item but with a link) 2. Create interfaces and share them amongst WCF as a link class and let all classes inherit the interface 3. Use RIA service and let the web app create auto code to expose it to silverlight.

Are there other options? and if not then which one is better for the scenario that I am facing?

Thanks


It's worth noting however that the .NET platform shipping with Silverlight is not the same as the one shipping with the full .NET Framework.

It means that there is little chance that the third party assembly will be compatible with Silverlight, even if SL uses the same IL. If the third party assembly only references mscorlib or System.dll, it could be compiled as a cross platform assembly between SL and WPF.

However, in all the other cases, the differences between the SL and full .NET platform will prevent the assembly from being compatible with Silverlight.

If the third party software has anything to do with UI or network, if the software uses Windows API... etc.. it won't work in a Silverlight App.

This is the reason why a general .NET assembly can't be referenced from a SL project. However, there are cases when a SL assembly can be used in an general .NET project.

If the assembly perform computational and asynchronous task however, you could execute it on the server, and send back the result to the Silverlight app.

For instance it's a great option if the class Library generates reports, files or images.

What does the third party library do?


If you don't have the source code, you can't reference the class library in your Silverlight application (as you probably know already). It is not possible to use standard .NET libraries in Silverlight without recompiling, because Silverlight is a different framework and a different CLR.

You can use the library on the server and create some services to access the functionality.

I don't think there is any other way to achieve your goal, unless you get the source code which you can put into a directory with the name Shared. It will then be copied to your Silverlight application and compiled in Silverlight.

0

精彩评论

暂无评论...
验证码 换一张
取 消