running client-server app in c# xamarin - c#

I started using Xamarin Studio for c# development and I wrote two 'Projects' in one 'Solution' - Server and Client. When I run Server, everything goes well, but the problem is, that I don't know how to run client at the same time.
Please help how to run both at the same time. I've googled but found nothing.

In the Solution options (right click the Solution in the Solution window and select Options) you can configure multiple startup projects in the Run - Startup Project section.
Testing this with Xamarin Studio 5.8 running two console apps, using Run - Start without Debugging, seems to work but debugging two console apps fails. Also you do not seem to be able to debug an ASP.NET app with a separate client app, but you can run both together without the debugger.
If you need to debug both then running two instances of Xamarin Studio will allow you to do that.

Related

How do I debug a Xamarin AIDL Bound Service with Visual Studio debugger?

I have a solution in Visual Studio with a Xamarin project that depends on another xamarin project inside the solution, and the comunication is made via AIDL.
If I deploy both projects separately to the Android emulator, It works flawlessly. The form is able to call the bound service. If otherwise I try to hit the "play" button to debug the application, it is not able to bind to the service via AIDL and I don't know why.
If I try to hit play having the service as startup project, it just deploys it and do nothing else.
I am not able to set breakpoints in the bound service and hit them.
I also tried to attach the debugger to the running process. But Visual Studio does not show me an option to do that with an Android application. =/
What is the best way to debug a xamarin project which depends on a bounded service (AIDL)?
Is there a better approach to expose a service to another Android application in such a way that I am able to reuse .net code and debug things naturaly?

How to I run a C# Framework API

The question may be a bit idiotic, but I can't find the answer on internet or Microsoft tutorials.
The goal of my project is to build an API to has to run locally on a Windows computer. My API mustn't have an interface or things like that, so I deleted every views and other files like bootstrap or jQuery. Then I call it with Unity.
The API works well, but I always run it with Visual Studio 2019. Is there something like a .exe or a command line to start my API ?
Thank you for your answers ! :)
PS : Yeah I know that an API running locally is quite useless, but with Unity it's really complicated to use things like pipes...
You can host your WebApi application in IIS, so you don't need to run it with Visual Studio.
If you are developing another project, you can ask Visual Studio to run multiple projects during a debugging session. While debuging your unity application, Visual Studio will run your API in the background:
https://learn.microsoft.com/en-us/visualstudio/ide/how-to-set-multiple-startup-projects?view=vs-2019
Otherwise, you may self host your asp.net webapi application.
There are official Microsoft tutorials on that:
For WebAPI 1:
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/self-host-a-web-api
For WebAPI 2: https://learn.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

Why can't I debug a simple Xamarin app that targets Android?

I am trying to create a simple Xamarin app on my Windows PC targeting Android and it is proving to be a real pain with problems at every single step of the way (no single step was without a lot of pain). I am now at the step where I am trying to start the device as shown below:
When I try to start this device I see the following error:
I have been trying to sort this error for the last 1.5 days with no luck. I have come across this webpage, which talks about the error: https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/android-emulator/troubleshooting?pivots=windows#accel-issues-win
Therefore I run the following command:
"C:\Program Files (x86)\Android\android-sdk\emulator\emulator-check.exe" accel
I see this:
Is this telling me that my CPU is not suitable for Xamarin development? My research is telling me that this is just warning me that debugging could be slower.
I have also come across this: https://visualstudio.microsoft.com/vs/msft-android-emulator/. I have installed it, but don't really understand what it is needed for because the Emulator appears to be installed as part of Visual Studio:
Now see the image below:
Notice I have enabled Hyper-V and Windows Hypervisor Platform.
What is the problem? Please note that I have created a basic HelloWorld type app i.e. using the project defaults.

deploy simple c# app to another computer from Visual Studio 2017

I have written a simple c# app to let my son do some stats on dice rolling for a game he is developing.
I created a simple interface using Visual Studio 2017 and Universal Windows.
After loads of silly errors - and lots of less silly ones, I finally have an app that runs as I want it to in debug mode.
I now want to publish it so he can copy the files and run it on his Windows computer.
Now I am sure this is really easy - but after 2 days of google searching, MSDN searching and searching this forum I am no nearer knowing what I need to do.
I have changed the solution configuration to Release and the platform to x86. I have run Build and Deploy solution form the build menu and have loads of files in my bin/x86/release file partial list from windows explorer.
But none of the exe files seem to do anything (the app5.exe waits a while sometimes, but no sign of the app anywhere).
I am obviously missing some critical preparatory step, but I can't find out what it is.
Some of the MSDN notes talk about Publish (this is greyed out or not present, but Deploy appears).
Can anyone please point me to some idiot proof documentation to help me work out what I should be doing.
I am new to Visual Studio, new to C# and new to windows app development - so my app has been pulled together from web research and using common sense :)
I have assumed that what I am trying to do is pretty easy - but I am not yet convinced.
To sell your Universal Windows Platform (UWP) app or distribute it to other users, you need to package it. If you don't want to distribute your app through Microsoft Store, you can sideload the app package directly to a device. Since you used the VS, you can follow this document to package a UWP app with Visual Studio: https://learn.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps#sideload-your-app-package.
After you package your app, if you want to sideload your app, you can follow the How do I sideload an app on desktop part in the following document:
https://learn.microsoft.com/en-us/windows/application-management/sideload-apps-in-windows-10#how-do-i-sideload-an-app-on-desktop
More details, you can get from this topic:
https://learn.microsoft.com/en-us/windows/uwp/packaging/

Adding windows service to a GUI-Windows application project

I have a GUI based windows application which is an .exe application(TestServer.exe )application. Now I need to add a windows service to this project solution.
So the solution would then build two executables. The first is the one it is currently building using the UserApplication; MyTestServer.exe
The second would be the new Windows Service; MyTestservice.exe.
Both would share the MyTestServerLibrary and our 3rd party dlls.
How can i do that in C# - Visual studio 2010?
As #nvoigt said, you simply add another project to your solution. If you'll right-click on your solution in the Solution Explorer window, select the Add|New Project... menu option. In the resulting dialog, select the Windows Service project type, give it a name, and press OK. Note that this step assumes you have one of the paid versions of Visual Studio 2010. My recollection is that the Windows Service project type is not delivered with the Express version.
From there, you simply build out your Windows service project just like you would any other project. If you've never done this before, I've got a set of instructions for how to do this here. The instructions target Visual Studio 2008 (I really need to update it...), but they are practically identical for Visual Studio 2010.
At this point, when you build your project, you'll get your TestServer.exe, any other C# assemblies that are part of your solution, and the newly-added Windows service executable. By default, running the Windows service directly from the Visual Studio debugger won't work for two reasons. First, your solution probably has TestServer.exe marked as the startup project, which simply means that when you press F5 to start debugging, the TestServer.exe will be run. But even if you change the startup project to be the new Windows service, it still won't work because services don't start the way normal Windows applications do. To get around this, you can look at the instructions here for how to have your Windows service operate in an "interactive" mode, which will let you debug it like any other application. For my purposes, though, I prefer to debug my Windows service when it's actually running as a Windows service. To do this, just put a call to System.Diagnostics.Debugger.Launch() in the constructor for your Windows service. Providing you are an administrator on your system, this will give you the opportunity to jump into a debug session when you start the service from the Services console.
This leads directly to the point of installing the service. To actually run a Windows service, it has to be installed on the system. For .NET-based Windows services, you can use the Microsoft-provided InstallUtil.exe to do this. If you open the Visual Studio command prompt from the Start menu, it's available in the directory path. I prefer the solution that Marc Gravell suggested to have the Windows service install/uninstall itself. I've got a set of instructions for how to do that here.
That should get you started. There are many good answers regarding Windows services on SO, so if you get stuck, be sure to search for it on this site. HTH.

Categories