MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

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

Open MarkOverstreet opened 4 years ago

MarkOverstreet commented 4 years ago

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

rockfordlhotka commented 4 years ago

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 commented 4 years ago

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.

clodewyks commented 4 years ago

Hi @MarkOverstreet / @rockfordlhotka ,

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

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.

MarkOverstreet commented 4 years ago

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.

rockfordlhotka commented 4 years ago

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.

MarkOverstreet commented 4 years ago

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?

rockfordlhotka commented 4 years ago

Are you using the version 5.1 prerelease?

MarkOverstreet commented 4 years ago

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.

rockfordlhotka commented 4 years ago

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 commented 4 years ago

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

MarkOverstreet commented 4 years ago

Ah okay I'll try that. Thanks