Vibrant discussion about CSLA .NET and using the framework to build great business applications.
Hi, I've just started playing around with the WinRT-build of CSLA. I've been working somewhat with CSLA.NET previously, so I'm familiar with the basic concepts.
Now what happens is that when I call DataPortal.FetchAsync<MyObject>("someParameter"), I get the following exception:
There was no endpoint listening at http://localhost:2114/WcfPortal.svc that could accept the message.InnerException: No connection could be made because the target machine actively refused it 127.0.0.1:2114
I'm making the assumtion that the dataportal is attempting to set up a WCF client-server for the dataportal. First of all, can I avoid that? It seems like an unneccessary overhead when I'm running both the client and server locally. I thought maybe I could add the [RunLocal] attribute, but it seems not to exist in CSLA.WinRt?
If I have to go with the WCF-method, then I'd like to know why I'm getting the exception. I thought at first it had something to do with permissions, but I have enabled "Internet (Client & Server)" in the appxmanifest-file.
Help appreciated
Frode,
Your data access is async and does not use Task (not supported yet). So Your DataPortal_Fetch should look like this:
public void DataPortal_Fetch(object criteria, LocalProxy<BusinessObject>.CompletedHandler callback){ try { Text = "Hello world"; callback.Invoke(this, null); } catch (Exception ex) { callback.Invoke(this, ex); }}
Since Your data Access code is going to call asyncronous webservices you must Accept a callback and is responsible to Call this to notify calling code that async operation is Complete.
This is probably going to change, see 3) in Rockys previous post but for the time beeing the callback parameter is required.
Jonny Bekkum, Norway CslaContrib Coordinator
The callback handler is specified in each Proxy type so for ObjectFactory the method should be like this:
public class BusinessObjectFactory : ObjectFactory { public void Fetch(object criteria, FactoryProxy<BusinessObject>.CompletedHandler callback) { try { var bo = new BusinessObject(); LoadProperty(bo, BusinessObject.TextProperty, "Hello world"); callback.Invoke(bo, null); } catch (Exception ex) { callback.Invoke(null, ex); } } }
Brilliant, that did it! I think we can officially close this thread now :-) Thank you both for the help.