I have built a UWP app, and a WPF app within the same solution. I am using the FullTrustProcessLauncher class to launch the WPF app from the UWP app. I am also using the AppServiceConnection class to allow the two apps to communicate with each other. This all works fine in a basic scenario. But once I start really developing my WPF app beyond the samples I can find I will need to start debugging in visual studio.
I've tried the following:
Set breakpoints within the WPF code.
Result: I did not expect this to work, and it did not.
Attach to the running WPF process once the UWP launches it.
Result: The "attach" button when the running WPF process is selected is grayed out.
I started investigating the new VS extension "Desktop Bridge Debugging Project" and followed along with samples and documentation.
Result: All of the samples I could find seemed to revolve around converting an existing WPF app to UWP. Because of this, I don't think this is a solution. I could be wrong...
Below is the relevant code for launching my WPF app from the UWP app:
int messageNumber;
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (this.messageNumber == 0)
{
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
}
this.messageNumber++;
await AppServiceManager.SendMessageAsync(
$"Message number {this.messageNumber}");
}
As I mentioned above, for now i'm just following the Microsoft examples. I would eventually like to add more complex code and be able to debug.
How else can I get debugging features for the WPF app launched from a UWP app?
Thanks
In order to debug the fulltrust process in your UWP project, you will have to start the UWP process without debugging (or detach the debugger from it). Then attach to the debugger to the fulltrust process and your breakpoints will be hit.
I realize this is not an ideal workflow, and we are working on improving this in a future update for VS.
Advanced Installer (a MSFT partner) provides now an extension for Visual Studio 2015 and 2017 that can build an AppX (along with your MSI/EXE) package from a single project and also enables debugging for your application with a few clicks - much simpler than current solutions.
- watch video demo -
Related
I have Xamarin Live Player up and running.
When I use it with a newly created Xamarin Forms (Master Details) app, it works fine. I see the app on the device.
However, when I try to run my full-blown app, Visual Studio tells me "Deployment to device failed. Make sure that Xamarin Live Player is open and that the device is in the same network."
Since the new app runs fine, I guess something else is the problem.
I've already set the Android project properties to be same as the newly created app.
Just to make sure, I've made it so that my full-blown app requests all rights.
How could I debug more in detail what's going wrong?
Xamarin Live Player can't run all apps. As soon as you use reflection, embedded resources, a MVVM framework or a custom renderer in Xamarin.Forms it might simply just not run the App.
You can read about the limitations of Xamarin Live Player in the official documentation for it.
You will probably have a much better experience just running directly on the device without Live Player.
For example I try to print out to the console and it doesn't, my script is attached to my main camera so we can rule that out and yes the script is active also, any help will be appreciated, right now what I am working on is to click on a certain part of my GameObject in AR and while my phone is connected to the computer I want to see the name of the certain part I clicked on in the console.
When you run the app on and Android device the log does not go to the Unity editor console. In order to see it you need to open Android Studio and then use the Logcat tab to see the device log.
Alternatively, you can run logcat from the command line
adb logcat.
More information: https://developer.android.com/studio/command-line/logcat.html
I have worked with ARCore and had the same frustating experience when it comes to debugging.
If you just want console prints, then use Log viewer which can catch and show them on Android too. (https://assetstore.unity.com/packages/tools/log-viewer-12047)
However, because I wanted more control and the ability to test and debug my game logic right inside the editor (without deploying to the phone all the time), I wrote a little plugin that allows me to do just that. This plugin simulates the operation of ARCore inside Unity editor. You can just hit play and ARCore will be simulated for you, so you can freely develop and debug your game logic. Moreover, you can then just build and deploy the project without changing anything, and ARCore will work like normal on your phone.
Using it is very similar to native ARCore, so you will not have much difficulty getting into it. It does not cover ALL features of ARCore yet, but it covers the basics. You can still use native ARCore for the rest.
You can find it here: https://github.com/VR-House/Eazy-ARCore-Interface
In current versions of Unity you can output logs from connected devices to Unity Editor. To do this, build your project in Development Mode and connect the Console to your device.
But I would recommend a more advanced way of testing AR in Editor with a plugin I wrote. I wrote it for my project and decided to make it into a plugin so everyone else can benefit from it.
AR Foundation Editor Remote plugin:
https://forum.unity.com/threads/ar-foundation-editor-remote-test-and-debug-your-ar-project-in-the-editor.898433/
I use debugging like this in C# script:
Debug.Log("Debug message and image name "+Image.Name);
To see this real time, I use Android Device Monitor (it's in Android's sdk folder, usually \Users\AppData\Local\Android\sdk\tools\monitor.bat. If device is connected, it appears on the devices list and it can be selected.
Or if I want to see the debug log in device, I put these lines in script:
private void OnGUI()
{
GUIStyle style = new GUIStyle();
style.fontSize = 50;
GUI.Box(new Rect(350, 0, 500, 500), Image.Name, style);
}
The Rect(350,0 is the position, 500,500 is the width and height of rectangle.
Using .NET Core and Xamarin I thought about building an application that would run on both Windows and macOS environments.
The .NET Core part would be used for all backend stuff and provide its functionality as a REST API. .NET Core however, does not have any support for building native UI applications (WPF, ...) so that's a no-go for building a tray application.
So I thought about using Xamarin for this. But I can't seem to figure out if this is at all possible. Nor can I find any leads on how to get started.
Some alternatives I've not yet further investigated:
Mono, but that doesn't have any integration with VS2017 so that's out...
QT, but that's aimed at C++, so that's out as well
Java, but then why bother using .NET Core in the first place...
Electron.js
For Windows, Xamarin.Forms will not officially support WPF till 3.0.
re: https://blog.xamarin.com/glimpse-future-xamarin-forms-3-0/
In terms of a Tray app, that is native Windows code and would not be a part of Xamarin.Forms UI code, but the native Windows code that would show/hide your app's UI (assumably Xamarin.Forms based)
For macOS, Xamarin.Forms is supported via Xamarin.Mac, and is currently in a "preview" release.
As far as the equivalent of a tool tray app on macOS, in Xamarin.Mac you can create a item (icon and/or text based) in the system status bar.
Typically this is done in the NSApplicationDelegate.DidFinishLaunching and is easy as:
statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(NSStatusItemLength.Variable);
statusItem.Button.Image = new NSImage("moviemadness_icon_dark.png")
{
Template = true
};
statusItem.Button.Action = new Selector("StatusItemButtonAction:");
In this example, any time the icon/text in the status is tapped, the StatusItemButtonAction method is triggered and it either terminates itself if you were holding the control key down at the same time, otherwise it runs the StatusBarPopOver which in my case constructs a NSPopover and shows an embedded Xamarin.Forms TabbedPage UI that shows the mobile app server status, current users of the app, the app analytics, etc...
[Action("StatusItemButtonAction:")]
public void StatusItemButtonAction(NSStatusBarButton sender)
{
var currentEvent = NSApplication.SharedApplication.CurrentEvent;
if (currentEvent.ModifierFlags.HasFlag(NSEventModifierMask.AlternateKeyMask) ||
currentEvent.ModifierFlags.HasFlag(NSEventModifierMask.ControlKeyMask))
NSApplication.SharedApplication.Terminate(this);
else
StatusBarPopOver();
}
I am developing Windows Phone 8 apps with Visual Studio and not being able to change the code while the app is running makes me crazy. I fall for it everytime. Trying to change the code before stopping debugging.
Tools > Options > Edit and Continue => I unchecked Enable Edit and Continue.
With above steps, I was able to change the code while the app is running but now I can't change design. How can I enable design editing while the app is running, too?
There is a very simple way of editing the design without ever running the app. If you open your solution in Blend, you can app sample data to your bound views based off the classes that they bind to. Then when you make changes in the XAML, they will update in the design view with the sample data.
http://blogs.msdn.com/b/pakistan/archive/2013/08/29/using-sampledata-in-windows-phone-8-using-blend.aspx
I have a simple Windows Phone 7 application which is working perfectly when started from Visual Studio. However, if I deactivate the app (press Windows button or back button from the application's MainPage) and then click the app's icon to relaunch, the screen will flash and return to the list/home screen. I assumed this was an issue with the emulator but when I got a developer device I have the same issue.
Note that reactivating without a complete tombstone works (pressing Windows button from the app and then back).
I have no idea what causes this or how to proceed with debugging. Hopefully someone else has experienced this and knows a fix.
Turns out there is a bug, i found the solution here http://forums.create.msdn.com/forums/p/67522/416995.aspx
In short, it turns out that the Microsoft.Xna.Framework.Media.MediaLibrary class (which I am using to display pictures on applications main page) is not properly initialized when the user has not opened a media hub prior to you calling it. So picture collection properties are null or empty. The solution is to add a call to MediaPlayer.Queue.ToString(), it will force the initialization of the native media library allowing you to invoke the MediaLibrary later on.
Sounds like an unhandled error on startup is causing the app to crash.
Trap/log/handle/display any unhandled exceptions. Also check what you're doing on startup.
IF you are saving something (to Isolated Storage) after first run and then opening it on subsequent launches then that's where I'd look first.
If it works when launched from Visual Studio then this will probably be due to the way you are rebuilding/redeploying the app before launching it in that case.