Sharing external SDK binaries to WPF and Silverlight - wpf

I've been trying to sort this out for some time now..
I have a few .NET libraries that work as an SDK to an external application. I need to use that SDK both from a WPF Class Library and a Silverlight Class Library. I've been reading a lot of solutions including:
Portable Class Libraries - When I try to add the SDK libraries to the project, it complains that those libraries reference .NET 2.0 libraries and it is incompatible.
WCF RIA - I may be doing this wrong, but everywhere I turn, one step of the process is to create an Entity with the EF. Now, I don't want to access a DB, just those libraries.
But so far, no luck. Any ideas you would like to share?

As far as I know, it may not work if the old .NET 2.0 binaries have references to COM or system libraries. That could relate to your DB implementation. I have had this problem in a project in a previous job. We solved this by creating a WCF service as a in-between solution. That was WCF and not WCF RIA.
If the .NET 2.0 code is really old, you should check if it must be compiled as x86 and hosted as a 32-bits application on AppPool of the site that hosts the WCF service in the IIS.
But this is tricky business, and it all depends on the complexity of the old .NET 2.0 library file and its references.

Related

Visual Studio project type for DTOs that should be accessible in Silverlight

What VS project type should I choose so that the data-transfer-objects that I create in it can be accessible in both in my Silverlight project as well as my WCF service project.
(I want to be able to reuse the DTOs that I define in both projects instead of having VS generate a new set in my Silverlight project when I create a web-service reference to the WCF service).
IE, my question is can the project be a Windows class library, or should it be a Silverlight class library (so as to reference it in both my Silverlight project as well as the WCF project).
You've got three main options:
Create two class library projects (one targeting Silverlight, the other the .NET Framework), and share the files between them, as I discuss in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-3.aspx
Create your class library as a Silverlight class library. Silverlight applications can't reference class libraries that target the full .NET Framework, but applications targeting the full .NET Framework (such as you WCF Service) can (generally) reference class libraries that target the Silverlight runtime.
Try out the Portable Library Tools (currently in beta): http://blogs.msdn.com/b/sburke/archive/2011/01/23/3-screen-coding-is-here-portable-library-tools-allow-you-to-target-multiple-net-platforms-with-one-binary.aspx
Have you thought of using RIA Services (or WCF Data Services) instead of a plain WCF service? RIA Services / WCF Data Services handles this problem for you, and adds other great functionality into the mix.
Hope this helps...
Chris Anderson

Silverlight / Prism / RIA : How to create the optimal infrastructure?

Since days I am reading and researching and still struggling how to create the perfect infrastructure. Since there are no Prism 4.0 templates as such, I came up with a strategy, but I need to be sure this is the right strategy and I would appreciate an advice from experienced PRISM/RIA developers.
I use PRISM 4.0, RIA Services 1.0 Sp1 Beta, Silverlight 4.0, Entity Framework 4.0
1) Client side
I created first a "Silverlight Business Application", which creates a Web.host and a Silverlight client application with implemented RIA authorization. The initially created Silverlight client application shall be used as the Shell project.
2) Infrastructure project (Common)
This project would contain some common Prism MEF attributes and perhaps the entity models that are auto generated by RIA as well as the Service Interface. The idea is to create a simple Silverlight Class Library, and under Properties of the project, I would select for the dropdown ‘WCF Ria Services Link ’ to point to the host.Web project that contains the Ria Services. Then after the rebuilding, I am able to see the entity models within the Class Library and these could then be shared between the prism modules to feed their ViewModels etc.
3) Service layer
Should I create the EF4 Model on the Web.host project and add the Domain Service in there? Then I would extract an interface from the Domain Service and put the interface into the Infrastructure (Common) project. The Web.Host therefore needs to reference the Infrastructure (common) project to get access to the interface. On the client side the interface may be used by MEF to retrieve or mock the service . However I am concerned about the service referencing a common project that contains also the client-side generated entities.
4) Authorization
Also a bit concerned about the authorization, shall I leave everything on the Shell project? Or do I have to move anything to the Infrastructure (common) project to share it?
Since this is my first time designing with PRISM, I might have misunderstood or forgotten some aspects. Please feel free to improve my suggestions.
Your help is highly appreciated
Kave
After two weeks of intense research, this blog couldn't put it better together:
http://blogs.msdn.com/b/dphill/archive/2009/08/17/prism-and-net-ria-services.aspx
There're nice Quick Start templates for Prism, I found it at blog http://blogs.msdn.com/b/dphill so it looks quite nice, I used it also created RIA Service library so everything now is separated:
1) WEb project
2) Ria Service on web
3) generated RiaService client code as separate and shared assembly and it is used by modules. that's it.

Are there Silverlight assemblies for Windows Azure SDK 1.2

Just wondering if there are Silverlight (4) versions of the following assemblies
Microsoft.WindowsAzure.StorageClient
Microsoft.WindowsAzure.ServiceRuntime
Microsoft.WindowsAzure.Diagnostics
No, these libraries are not compatible with silverlight. First, the ServiceRuntime and Diagnostics libraries are completely useless to silverlight. Those are only relevant to hosted roles. As far as the StorageClient, while there is no dll for that there are a number of different approaches. I would recommend using the newly release RIA services for table storage as part of your solution. You can find that here: http://www.silverlight.net/getstarted/riaservices/
Also see this discussion for more details. Basically, you will want to use WCF services to expose you blob storage, etc. to your silverlight client. http://social.msdn.microsoft.com/Forums/en/windowsazuredevelopment/thread/b5e6775a-289f-438d-be79-8414f08c5c78

Sorrow with Data Transfer Objects in Silverlight / WCF

I have a Silverlight app hosted in an Azure web role ASP project. The ASP project exposes a WCF service.
I would like to have one set of class definitions for the data types. Someone recommended making a third project (class library) and adding a reference to it from the SL and ASP. I started doing this, but the Silverlight project complained that you can only add references to Silverlight projects.
I then made a Silverlight class library and moved the data classes to it. However, I to add some .dll references, like to the Windows Azure storage client. Then the Silverlight class library tells me I can only add references to Silverlight 4-friendly .dlls, of which Windows Azure isn't one. Fantastic.
Is there something I can do to get around this, or am I stuck with a less elegant, redundant solution?
Multi-targeting is your best bet. There is an article explaining this in Visual Studio from Microsoft at:
http://msdn.microsoft.com/en-us/library/ff921092(PandP.20).aspx
Basically, you create both your Silverlight and standard .NET class libraries, each with a different name, and then include the same files into each. Usually the files are actually only in one of the class libraries and then soft linked in the second one.
The key is to ensure that the code in your files is compatible with both runtimes. If there needs to be separate implementation for some of your methods depending on the runtime then you need to separate these with pragmas (i.e. #ifdef SILVERLIGHT...).
If you're only doing data structures, however, there should be no issues as long as Silverlight supports the objects you are using.
See if using linked files as per this answer does the trick for you.

Sharing assemblies between .Net 4 and Silverlight 4

At the last PDC (can't remember which talk it was) they gave us the information that it will be possible to share assemblies between regular .Net 4 and Silverlight 4.
Unfortunately I can't find anything on this. Was this feature dropped? What options/limitations are there?
(There are similar questions on SO but they don't say if they apply to SL3 or 4.)
See Sharing Silverlight Assemblies with .NET Apps from the CLR Team Blog.
Basically if your assembly only references:-
Mscorlib
System
System.Core
System.ComponentModel.Composition
Microsoft.VisualBasic
That assembly can be shared by both frameworks with each framework using its own version of those references (that is .NET won't be attempting to load Silverlight's version of System.Core for instance).
Of course you will still need to limit your code to features of these references that are actually common across to the two frameworks.

Resources