How to set debug level when deploying using Azure ARM template with C#
var deployment = azure.Deployments.Define(parameters.DeploymentName)
.WithExistingResourceGroup(parameters.ResourceGroupName)
.WithTemplate(vmTemplate)
.WithParameters(deploymentParameters)
.WithMode(DeploymentMode.Complete)
.Create();
In Powershell, there is an option we can use:
New-AzureRmResourceGroupDeployment -deploymentdebuglevel
source
As Suggested by mtz1406 you can try checking the below debug setting class in ARM template.
public class DebugSetting
Inherite the object as debug
Here is the Microsoft Documentation for Debug class setting.
Related
I have a C# WPF application. It uses a small commercial framework (https://www.inosoft.com/en/product/product-features/).
I'm building this application both locally and via a buildserver (Azure pipelines). I use a marketplace task to change the assemblyinfo.cs before building: https://marketplace.visualstudio.com/items?itemName=bleddynrichards.Assembly-Info-Task
The build server executes the following tasks:
NuGet restore
Inject/Edit assemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion with the right version info
Build
Now when I run this application, it starts up and runs for a while.
Quickly after starting I hook the VS debugger into the process.
Then all of the sudden the application crashes:
This is weird, because when I build locally, this runtime error does not occur.
Note that i set all properties to the same values for testing:
AssemblyVersion: 1.2.3.4
AssemblyFileVersion: 5.6.7.8
AssemblyInformationalVersion: 9.10.11.12
I then use Telerik justAssembly to compare the build output from my local build and the buildserver:
As we can see the local output (on the left) does not have a version added to the Application.LoadComponent(..) whilst the build server output (on the right) does.
public void InitializeComponent()
{
if (!this._contentLoaded)
{
this._contentLoaded = true;
Application.LoadComponent(this, new Uri("/HmiMetis;component/views/app.xaml", UriKind.Relative));
}
}
This means that this is the root cause of the runtime exception.
I find it weird that the build process on my local machine differs from the build server output. Both (should) use visual studio 2017 to build. Why does the buildserver add the version to the uri of loadComponent and my local machine does not?
Anyways, I need this exception gone.
Therefore I think the easiest way would be to force the buildserver to not add the version information under any circumstances. Is this possible and how?
Edit:
I Found a relating issue report that may have something to do with this:
https://github.com/dotnet/core/issues/3189
How is (cross-platform) logging achieved with Uno? (to console, mainly)
I'm using Visual Studio, starting the UWP Head, and when i try to write something to the log, I'm expecting it to appear in Visual Studio Output windows / Uno Platform output, but nothing shows up there.
I'm using the following code (that i found in various repositories, as a supposed 'standard' way to log), in a UWP page 'code behind' code:
this.Log().LogInformation("My log");
but, as I said, nothing appears in the output windows.
The documentation says that to enable console logging you should use the following code:
Uno.Logging.LogManager.LoggerSelector = Uno.Logging.ConsoleLogger.Instance.GetLog;
Uno.Logging.ConsoleLogger.Instance.LogLevel = Uno.Logging.LogLevel.Warn;
Uno.Logging.ConsoleLogger.Instance.Filter = (level, name, message, exception) =>
{
// Provides a list of loggers that should be displayed to the console
var passList = new[] {
"Windows.UI.Xaml.VisualStateManager",
"Windows.UI.Xaml.VisualStateGroup",
"Windows.UI.Xaml.Controls.RadioButton",
};
return passList.Any(n => name.StartsWith(n))
? Uno.Logging.ConsoleLogger.FilterResult.Pass : Uno.Logging.ConsoleLogger.FilterResult.Ignore;
};
but the types Uno.Logging.LogManager and Uno.Logging.ConsoleLogger are not existent. Are they defined in additional libraries/nuGet packages? And where does this code should be placed?
EDIT:
This happens only with the UWP head. With the Wasm head, the log messages show correctly in browser's console, and with Android head (running in an emulator) they show up in Visual Studio's Output/Debug window. Can't try the iOS head, sorry.
Environment:
Visual Studio 2019 16.7.3
Uno.Core 2.0.0
Uno.UI 3.0.17
Uno.UI.RemoteControl 3.0.17
Uno.UI.WebAssembly 3.0.17
Uno.UniversalImageLoader 1.9.32
Uno.Wasm.Bootstrap 1.3.4
Uno.Wasm.Bootstrap.DevServer 1.3.4
When you are calling this.Log(), it will capture the fully qualified named of the this's type.
If you add the namespace of this type to the passList, it should work.
When you create a project using the template, you'll see a ConfigureFilters method in the App.xaml.cs file. Add you namespace there in the .WithFilter() call.
Example of such call here.
I'm trying to set up a very simple test application for connecting to my Firebase Cloud Firestore instance.
It's a C# .NET Core console application using .NET Core 3.0 on Windows 7
I'm just trying to connecting to my Firestore instance using my project name.
My GOOGLE_APPLICATION_CREDENTIALS environment variable is set to C:\test\creds.json which I created from using the "Create Key" feature on the GCP Console page for my default service account.
When I run the code below, I get the following error:
using Google.Cloud.Firestore;
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
FirestoreDb db = FirestoreDb.Create("my-proj-id");
}
}
}
Exception:
The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials. See
https://developers.google.com/accounts/docs/application-default-credentials
for more information.'
When I run ProcessMonitor to detect file system activity, my application never even tries to touch the creds.json file, which makes me believe the C# Cloud Firestore API isn't even finding my creds file. I've set the GOOGLE_APPLICATION_CREDENTIALS env variable at both the user and system level.
Is there a problem with how I've configured things?
Well this was maddening. I tried to log the GOOGLE_APPLICATION_CREDENTIALS environment variable value in my app and it was null. I restarted Visual Studio and it started to work. My theories are that either VS passed the current environment to the debugee when it launches the debugger process or that it may use one of those Visual Studio debugger host proxy processes for debugging and it was restarted after I restarted the IDE
Sometimes the environment that Visual Studio is running can be different to the scope of the PATH ENV variables in Windows. I think it is related to the Admin permission. It would be interesting to execute the task and the GOOGLE_APPLICATION_CREDENTIALS assignment opening Visual Studio as Administrator.
Seems that this behavior is expected. C# .net MVC, set path to Google Application Credentials JSON file
I'm writing an Android Wear app using Xamarin. I'm using the Microsoft.Extensions.DependencyInjection library to handle service dependency injection in my app. It works completely fine when I run the app in Debug mode through Visual Studio (Ctrl + F5), on my actual smartwatch. The app functions correctly and everything. When I publish the app using the "Archive..." function of the Xamarin toolset and then sideload the published version onto my Smartwatch, however, the app crashes at startup with an exception stating System.InvalidOperationException: A suitable constructor for type 'My.Library.SomeManager' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.. This spawns from a call to IServiceProvider.GetService for the SomeManager type.
I don't know why this would be. I'm logging to logcat when I register the services, and can see them being registered in the published version, but for some odd reason, the dependency injection engine is not able to find them. I don't know enough about the inner workings of Xamarin to choose a direction to troubleshoot this. Does anybody know what would be causing this odd behavior?
Assuming your Release configuration has the Linker set to something other than None?
Classes, constructors and/or methods that are only referenced via reflection calls for activation and used via interfaces (typical for DI) can not be seen by the static analysis that the Mono Linker performs and thus are stripped from the assembly(s) in order the get the final app bundle size down to a "acceptable" size.
Note: This process is comparable to the Proguard tool, and its replacement,R8, used to strip un-used Java code and has the some "limitation" and most of my Xamarin.Android projects end up with a custom Mono linker and Proguard/R8 config file.
If you do not "own" the code that is being stripped, you can manually reference a class/method so the Linker does not strip it:
[Preserve]
public static class LinkerPreserve
{
static LinkerPreserve()
{
throw new Exception(typeof(My.Library.SomeManager).FullName);
}
}
If you own the code, you can apply the PreserveAttribute to the class.
[Preserve]
public class SomeManager
{
~~~~
}
You can also apply the --linkskip=ASSEMBLY in the build options...
Refer the docs for details:
https://developer.xamarin.com/api/type/MonoTouch.Foundation.PreserveAttribute/
It take full control of the Mono linking process you can create a custom linking config file:
https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker
Has anyone been able to get an extension up and running Expression Blend + Sketchflow preview? I'm looking for an example project.
I was following this article, but it is a bit outdated.
So far I:
Created a .Net 4.5 class library project
Added a reference to the Microsoft.Expression.Extensibility.dll in the new Blend Preview directory
Set my project to deploy to the appropriate Addins directory
Setup Visual Studio to run the new Blend.exe for debugging
Hooked up MEF and inherited IPlugin as in the example
But my plugin doesn't seem to load and no breakpoints are hit.
After reading your question I decided to start working on a new version of that tutorial.
A few things to get you started right away.
I've created the basic plugin like this:
using System.ComponentModel.Composition;
using Microsoft.Expression.Extensibility;
namespace Demo.Extension
{
[Export(typeof (IPackage))]
public class Demo : IPackage
{
public void Load(IServices services)
{
}
public void Unload()
{
}
}
}
Make sure you:
place the plugins in ...\Blend Preview\extensions
run visual studio as administrator to be able to deploy to that folder during debug
implement the IPackage instead of IPlugin
Got it working by following the demo here.
I used the few modifications above, and put things in the Blend Preview directory.