Open RIA Services User Support Test WPF Application  Viewed 124776 time(s), 13 post(s)., 5/8/2015 3:41:32 PM - by westwok

westwok
westwok 5/15/2015 4:22:18 PM

Hi All, 
 
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: 

Web 

1. Install Visual Studio 2013 Extension - Open Ria Service Tooling and Template (v1.3.2.2) 

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) v4.4.0.0 

6. Install nuget package - Open Ria Services Server components v4.4.0.1 

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 

 

Client 

1. Add a WPF project to the solution 

2. Install nuget package - Open Ria Services Client, Code generator and MVVM Support v4.4.0.4 

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. 

 
Kind Regards 

Kevin 

 

 

Rated 4.00, 1 vote(s). 
45 Reputation 4 Total posts
1
rfrick
rfrick 5/13/2015 4:13:20 AM

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.

Good luck!

This content has not been rated yet. 
134 Reputation 10 Total posts
2
westwok
westwok 5/13/2015 10:28:57 AM

Hi RFRICK,

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.

http://blogs.msdn.com/b/kylemc/archive/2010/05/14/ria-services-authentication-out-of-browser.aspx

Now if only I can resolve the ValidateDomainServicesTask problem I'm all good to go.

This content has not been rated yet. 
45 Reputation 4 Total posts
3
rfrick
rfrick 5/15/2015 2:49:32 AM

Hey West,

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!

Ron




This content has not been rated yet. 
134 Reputation 10 Total posts
4
westwok
westwok 5/15/2015 10:26:19 AM

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 :

<Target Name="CoreValidateDomainServices" Condition="'$(EnableDomainServiceValidation)' == 'True'">
  <ValidateDomainServicesTask
     ProjectPath="$(MSBuildProjectFullPath)"
    AssemblyFile="$(MSBuildProjectDirectory)\..\packages\OpenRiaServices.Server.4.4.0.1\tools\OpenRiaServices.DomainServices.Tools.dll"
     ReferenceAssemblies="@(BuiltProjectOutputGroupDependency)">
  </ValidateDomainServicesTask>
</Target>

I'm sure there's a simple resolution to this but it's beyond me at present. The relative path must just be wrong or something else.

We have not started the conversion quite yet.  At present I'm just trying to prove that OpenRIA Services\WPF is a viable migration path. We have a Silverlight application using the Navigation framework and PRISM.  If OpenRIA Services looks good then our first task will be just to upgrade our current application from WCF RIA to OpenRIA.  Once done then we will create a WPF client and start to migrate everything over from Silverlight to WPF.

This content has not been rated yet. 
45 Reputation 4 Total posts
5
ColinBlair
ColinBlair 5/18/2015 6:32:26 PM

I personally have been stuck in Silverlight land and have started working on some ASP.NET MVC projects but nothing that needs something like RIA Services. I had hoped that I would be porting my old Silverlight apps to WPF or WinRT and I could drag Open RIA Services along with me but it is looking like that isn't going to happen. Instead, it looks like my old apps will be moving to full on HTML/JavaScript probably using Type Script and Angular2.

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.

This content has not been rated yet. 
1539 Reputation 130 Total posts
6
rfrick
rfrick 5/21/2015 5:27:29 PM

Colin,

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.

Thanks again,

Ron

This content has not been rated yet. 
134 Reputation 10 Total posts
7
tomas
tomas 8/26/2015 1:47:05 PM

Hi,

I am following the same journey as Westwok. I have now converted SL project to WPF and now finally I am trying to run it.
I have something like this in my app.xaml:
           <dataComp:RiaContext x:Key="RiaContext">
                <dataComp:RiaContext.Authentication>
                    <openRia:FormsAuthentication DomainContextType="RiaServices.Server.AuthenticationContext, RiaServices.Client"/>
                </dataComp:RiaContext.Authentication>
            </dataComp:RiaContext>

that RiaContext is: public sealed partial class RiaContext : WebContextBase ...

Problem is in constructor of AuthenticationContext, I am getting this:
ArgumentException: The specified service URI is not correctly formatted.
So how to resolve it? - How to say to WPF to use http protocol?

My second problem is that when I am using VisualStudio 2015, I found out that it has problem with intellisense in one of client part of OpenRia project. It is interesting that I have two OpenRia projects in my solution and this problem is only with one of them.

Thank you for your help in advance,
Tomas

This content has not been rated yet. 
16 Reputation 3 Total posts
8
Daniel-Svensson
Daniel-Svensson 9/1/2015 7:00:23 PM

@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. 

This content has not been rated yet. 
338 Reputation 44 Total posts
9
tomas
tomas 9/8/2015 12:55:07 PM

Hi Daniel,

Thank you, fortunately I was able to figure it out myself earlier, so now there is only problem with intellisense in VS 2015 remaining...

Cheers,
Tomas

This content has not been rated yet. 
16 Reputation 3 Total posts
10
1 2