cslaforum icon indicating copy to clipboard operation
cslaforum copied to clipboard

VS2019 & SQL Server & Xamarin Forms & CSLA.NET - How to debug in development?

Open MarkOverstreet opened this issue 5 years ago • 11 comments

My company is doing 3 new mobile app, Xamarin Forms projects and I am trying to get them to use CSLA.NET (new to this framework other than using it for 1 WPF app) but one big question that came up is how to debug during development since you can't write to the sql server database directly?

I'm assuming you don't have to deploy to your server and run the app each time you make a code change and lose the option to do live debugging?

Any help and instructions on how people are doing mobile development with CLSA.NET would be appreciated so that I can make a better case to use this framework.

Thanks

MarkOverstreet avatar Feb 02 '20 23:02 MarkOverstreet

The challenge you describe is not unique to CSLA - it is something inherently challenging to using Xamarin - attaching a debugger to the client app and the app server code.

The hard part of this is that your device or emulator can't interact with localhost.

I find the easiest solution is to use Azure to host my app server, because you can easily publish to Azure from VS and also attach a debugger to Azure.

rockfordlhotka avatar Feb 03 '20 02:02 rockfordlhotka

The other challenge you'll likely encounter with Xamarin.Forms is that it is somewhat easy to create a memory leak based on how you implement navigation in the app. Again, not entirely a CSLA thing, though the interaction between your views and your model (in this case CSLA models) is what causes the leak.

The Kids Id Kit app uses CSLA and has code in the navigation model to avoid view<->model leaks.

rockfordlhotka avatar Feb 03 '20 03:02 rockfordlhotka

Hi @MarkOverstreet / @rockfordlhotka ,

A simple solution to debugging the above mentioned project in development would be to:

  • Set multiple startup projects (Android / IOS project and AppServer)
  • Install Conveyor by Keyoti from the marketplace
  • Add firewall rule to allow inbound traffic on Conveyor port (normally 45455)
  • Set DataPortal URL to conveyor URL instead of localhost

The challenge you describe is not unique to CSLA - it is something inherently challenging to using Xamarin - attaching a debugger to the client app and the app server code.

The hard part of this is that your device or emulator can't interact with localhost.

I find the easiest solution is to use Azure to host my app server, because you can easily publish to Azure from VS and also attach a debugger to Azure.

clodewyks avatar Feb 03 '20 04:02 clodewyks

Thanks, that is some great info. I'll check out the Kids app and the Conveyor utility!

By the way, I just created a simple Xamarin forms app with a button that instantiates a basic CSLA class (from our WPF app) and is used to send email (EmailCommand). However, in WPF we used WCF to run this command class on the server and I'm just wondering if there are any instructions anywhere that tell me how to set up the DataPortal for a Xamarin Forms app? I'd like to get this sample program running just to prove it will work so if you could point me to any documentation for this, I'd appreciate it. I did check out the samples but didn't see anything that appeared to demonstrate this.

Thanks in advance.

MarkOverstreet avatar Feb 07 '20 06:02 MarkOverstreet

You can't use WCF because WCF is largely unsupported in modern .NET, including Xamarin. You should use HttpProxy instead.

The current ProjectTracker sample shows how to configure the app server and also configure the Xamarin client.

rockfordlhotka avatar Feb 07 '20 07:02 rockfordlhotka

Okay just checked out the client code and it seems this simple, just copy these lines into my sample Xamarin Forms project..

using Csla.Configuration;

CslaConfiguration.Configure() .DataPortal() .DefaultProxy(typeof(Csla.DataPortalClient.HttpProxy), "https://xyz.net/api/dataportal");

However, ".Configure" does not appear to be a static method of CslaConfiguration so I'm getting a build error. I've looked at your client code and I'm not sure what I'm missing? I'm sure it is something simple, any thoughts?

MarkOverstreet avatar Feb 07 '20 20:02 MarkOverstreet

Are you using the version 5.1 prerelease?

rockfordlhotka avatar Feb 07 '20 21:02 rockfordlhotka

I used Manage Nuget and I just checked and it is...

CSLA-XamarinForms 4.11.2.

I don't see a way to get anything higher. When I look at the Update tab this is the latest.

MarkOverstreet avatar Feb 07 '20 21:02 MarkOverstreet

The package names change from version 4 to version 5. So the new package name is Csla.Xamarin.Forms.

The latest released version is 5.0.1.

The almost-finished version is 5.1, and there's a prerelease available if you check the box in VS to allow prereleases.

rockfordlhotka avatar Feb 07 '20 21:02 rockfordlhotka

More info on the updated package names is here https://github.com/marimerllc/csla/issues/1151

rockfordlhotka avatar Feb 07 '20 21:02 rockfordlhotka

Ah okay I'll try that. Thanks

MarkOverstreet avatar Feb 07 '20 21:02 MarkOverstreet