I have a large Silverlight application that links to WCF RIA Services and I'm looking at migrating it to WPF. As part of my investigation I thought I'd create a new WPF application that linked to Open RIA Services. I thought It might be useful to share the steps I took to create the application and the problems I came across on the way. Maybe you can point out where I could have done things differently and maybe some suggestions to my remaining problems?
Here's how I did it:
1. Install Visual Studio 2013 Extension - Open Ria Service Tooling and Template (v22.214.171.124)
2. Install Open RIA Services Tools Support Installer from codeplex -
3. Create ASP.Net web application project in Visual Studio.
4. Add a solution folder and move the project into it (do this because there's a bug that exists when the web project is in the root of the solution)
5. Install nuget package - Open Ria Services for Linq to sql (Datacontext) v126.96.36.199
6. Install nuget package - Open Ria Services Server components v188.8.131.52
7. Add a LinqToSQL datamodel (The Silverlight app I'm migrating from uses WCF RIA LinqToSQL)
8. Build solution
9. Add a domain service and use the tooling to generate if from the datamodel above
1. Add a WPF project to the solution
2. Install nuget package - Open Ria Services Client, Code generator and MVVM Support v184.108.40.206
3. Add references to System.Runtime.Serialization, System.ServiceModel, System.ComponentModel.DataAnnotations
4. Use the tooling to Link the WPF project to the Web project and build.
5. In the client write some code to instantiate a domain context and load it using one of the queries.
Had to change the URI to my sql express localhost
DataContext.Load only returns an object and not LoadResult<T>. OpenRiaServices.DomainServices.Client.OperationBase does not user generics in the eventhandler args so you have to cast the sender object to an OpenRiaServices.DomainServices.Client.LoadOperation<T>
LoadAsync works fine so went with this.
All of the above worked OK and it successfully populated a DataGrid with some data.
I have a couple of remaining problems:
1. Error 1 The "OpenRiaServices.DomainServices.Tools.ValidateDomainServicesTask" task could not be loaded from the assembly OpenRiaServices.DomainServices.Tools. Could not load file or assembly 'OpenRiaServices.DomainServices.Tools' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ORS.
I have followed some suggestions in here http://bit.ly/1Jw0yCX but it's not yet resolved the problem.
2. The Silverlight app I'm migrating from uses the AuthenticationDomainService with the SqlMembershipProvider. I have successfully used the Open RIA Services AuthenticationDomainService to get a user to login. However, when I next call another domain service that has the RequiresAuthentication attribute it returns 'Access to operation was denied'. On the server the System.Web.HttpContext.Current.User.Identity is empty and IsAuthenticated is false. I'm sure I'm missing something simple here.
Very Nice! I would be very interested to see how the rest of this project goes for you. I have never done this before but I image that you will have to store the authentication in a cookie. Maybe this can help. http://www.garrardkitchen.com/2009/09/forms-authentication-wpf/
Maybe Colin has done this before and can offer another suggestion.
Your reply pointed me in the right direction. I looked at the article, and a couple similar, for forms authentication with WPF & WCF and they didn't quite fit since we are using WCF all wrapped up in a RIA services DomainContext. What I did find though was an article by Kyle McClellan about forms authentication for out-of-browser Silverlight\RIA services scenarios. Since this is RIA services and WPF is out-of-browser (kind of) then this had more synergies with what I'm trying to achieve. I implement this and it works a treat.
Now if only I can resolve the ValidateDomainServicesTask problem I'm all good to go.
Excellent find! Glad it helped a little with the cookie idea. I would love to keep up and hear how your project is coming along even after you get past the ValidateDomainServiceTask. I did see this on the OpenRia Forms. ValidateDomainServicesTask . Good luck!
I too have a very large RIA app that I love, but at this point we need to make a decision about leaving out investment in XAML and going Full HTML5 or porting it to WPF and having a limited set of features in HTML. So far how painful has it been in your conversion process? Did you develop SL using pages and implement the navigation:Frame?
Keep up the good fight!
I also noticed that forum post about the ValidateDomainServiceTask issue. Since then the nuget package structure seems to have changed slightly and the OpenRIaServices.Server.targets file is now in a separate folder called 'build'. I've tried editing the target file as suggested like this :
"'$(EnableDomainServiceValidation)' == 'True'"
This means that if anyone finds a problem in the core Open RIA Services code (for example, the DomainService isn't processing a ChangeSet correctly) then I can handle that easily, but any integration issues like how to implement authentication correctly in a WinRT application will only be guess work. My guess is that the AuthenticationDomainService and WebContext should be needed outside of Silverlight. The point of the AuthenticationDomainService and WebContext was that Silverlight didn't have access to the usual security APIs so the AuthenticationDomainService and WebContext were needed to provide role based security to Silverlight. In WPF and Windows Store apps you should have access to the full security model so you can access the role based security directly.
For the Validate problem, the ValidateDomainServicesTask isn't required for OpenRIAServices to function so you can just remove the task completely from the project file if you can't get it to work. The validation primarily checks things like making sure that one exposed DomainService doesn't inherit from another exposed DomainService.
Thanks for taking the time to let us know how things are
going for you and what you are working on. I'm still not wanting to
face the fact that we have to move forward using HTML, but I need to get with the times as they say. :( You were able
to get the monumental task of open sourcing RIA Services done, why not
shoot for Silverlight too. :)
I was really interested in helping out on this thread because I too want to take all the work we did with our Silverlight client and put together a click once delivered WPF app for our power user who are not going to enjoy the new web version as much as they do our Silverlight client.
For the authentication, did you mean to write "AuthenticationDomainService and WebContext should not be needed outside of Silverlight"?..since we will have a full security model in .net.
@Tomas I replied to your problem with argument exception in the other thread http://openriaservices.net/MonoX/Pages/SocialNetworking/Discussion/dtopic/B5lhO9CL90aEpaSwAV6QUw/Troble-calling-Login-method-of-the-AuthenticationService/
As for better WPF support I have some ideas of trying to add the shared cookie container by default as well as a simple way to provide the base server uri så that you don't manually have to provide full URI when creating all domain context.
Thank you, fortunately I was able to figure it out myself earlier, so now there is only problem with intellisense in VS 2015 remaining...