Open Abenzio opened 4 years ago
Where are you hosting the app server? You can not host it on localhost when using the Android emulator, because the emulator won't have access to your local machine.
I typically host my app server in Azure when building mobile apps, because that puts the app server into the cloud where it can be reached by my dev workstation, my emulators, and my real phone.
I'm hosting my app server on Azure. The DataPortalProxy and the DataPortalUrlString are both being set in the OnStart() of the App.cs.
I'm able to call DataPortal_Create and Get methods synchronously, and when I make a conventional web api call to a regular API controller using Android that works too.
It's only when I try to make async calls through CSLA to my Azure app server that android has an issue.
Thank you for bringing this to my attention. There does appear to be a bug in (I think) the configuration subsystem, where ApplicationContext
is being lost in Xamarin. That might not be the only issue - but at least in my initial attempt to replicate your issue I'm finding that the data portal proxy is being reset to "Local" before the data portal call.
This might be different from your issue - but I can't get to your issue because I can't get the data portal to actually make a remote call just at the moment.
Whew! No problem with the configuration subsystem - just me being an idiot 😄
In ProjectTracker I wasn't configuring the data portal until the OnStart
event, but that's too late, because I'm loading some data earlier in the app lifecycle. No wonder the configuration seemed wrong - it hadn't even occurred yet!!
Thank you for attempting to look into it.
I feel like this is going to end up being an issue on my end, but so far I haven't found exactly what I'm missing to bring it all together.
I'm not sure what to suggest. ProjectTracker is now working fine, once I configured the data portal before trying to use the data portal, so I don't think there are any specific issues with the HttpProxy.
Are you trying to retrieve a particularly large object graph, or an object with a large amount of data?
No, it's a pretty small amount of data. Even that Foo example I showed in my post fails, and that's not doing anything but returning hardcoded values.
Maybe I have some sort of dependency that needs to be updated. I've looked over that, but I suppose I could have missed something.
I was able to find some time to look at this issue again.
It was just the HttpClient implementation settings for the iOS and Android projects. I set it to Default in Android and Managed in iOS to match the ProjectTracker project and that fixed the issue.
Well, full disclosure, I can't be 100% certain if that's the only thing I changed in iOS. I had a few issues getting it working after that, and I lost track of what I changed in the moment. The main point, however, is that the original error was fixed by adjusting the settings in my Android and iOS projects.
Right-Click the Android project > Properties > Android Options > Advanced > HttpClient Implementation > Default
Right-Click the iOS project > Properties > iOS Build > HttpClient Implementation > Managed
So, while this wasn't a CSLA issue, if someone else runs into this issue, this is how I fixed it, because the defaults for the Android and iOS projects in Xamarin.Forms will give you this issue.
I have a simple client application in Xamarin Forms that is talking to an App Server (Azure). When I run the UWP version of my application everything works fine. I can create new objects, fetch a list, fetch an individual object, etc. However, if I run the Android version, I cannot do any sort of dataportal fetch or create asynchronously. In Android I get the error: "Csla.DataPortalException: 'Unable to read beyond the end of the stream.'"
As an example, I have the simplest object I could come up with:
To call these factory methods I'm using this in my view model:
My app server has a basic setup with the HttpPortalController:
Whenever I call an async method in Android it gives me the error:
And the stack trace from the error info from the data portal exception is:
I've had this issue with 4.11.2, 5.0.0, and 5.0.1.
I hope it's just a misunderstanding on my part and I'm just missing some obvious piece of the CSLA setup, but I haven't been able to find it.
Any help or nudge in the right direction would be greatly appreciated.
Version and Platform CSLA version: 4.11.2, 5.0.0, 5.0.1 OS: Windows, Android Platform: Xamarin, Azure