Get visual studio debug event in VS extension - visual-studio

How do I write an extension to Visual Studio that will run during debug?
I saw kinds of UI or code editor options, but not the software events.

DTE.Events.DebuggerEvents gives you access to VS debugger events:
events = DTE.Events;
debuggerEvents = events.DebuggerEvents;
debuggerEvents.OnEnterRunMode += OnEnterRunMode;

Related

How can one debug embedded code in razor pages?

I am looking at Blazor client side with asp.net hosting. So I am going through the template project and Visual Studio Preview does not seem to support breakpoints in razor pages, more specifically the code block:
#code {
private WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("WeatherForecast"); //breakpoint here
}
}
Is there a workaround or maybe something I am missing?
Thank you!
Blazor Webassembly debugging is currently available only using Chrome browser debugging proxy. The steps are described in Blazor docs:
Run a Blazor WebAssembly app in Debug configuration.
Pass the --configuration Debug option to the dotnet run command: dotnet run --configuration Debug
Access the app in the browser.
Place the keyboard focus on the app, not the developer tools panel. The developer tools panel can be closed when debugging is initiated.
Select the following Blazor-specific keyboard shortcut:
Shift+Alt+D on Windows/Linux
Shift+Cmd+D on macOS
Follow the steps listed on the screen to restart the browser with remote debugging enabled.
Select the following Blazor-specific keyboard shortcut once again to start the debug session:
Shift+Alt+D on Windows/Linux
Shift+Cmd+D on macOS
The "Hit F5 in Visual studio" debugging experience is not ready yet. Bits of it have been demonstrated by Daniel Roth in the .NET community standup video. Basically, Visual studio can attach to the browser's debugging proxy. Currently, in the preview versions, you have to do a series of steps manually, while in the future, those should be streamlined and done by the Visual studio.
Update March 26, 2020
Microsoft released a new preview of WASM Blazor and an improved support for debugging in Visual studio. Details here.

How to enable and disable ServiceHub.exe components in Visual Studio 2017

How can I disable it?
In the following screenshot you can see six processes that all begin with ServiceHub. These start when I start Visual Studio 2017 Community. Annoyingly, they do not stop when I exit Visual Studio 2017 Community. I would like to know how to disable these so that they do not start in the first place.
How can I enable it?
What turns these on?
Screenshot
First Workaround:
Tools > Options > Text Editor > JavaScript/TypeScript > Language Service...
Uncheck Enable the new JavaScript language service.
OR:
Tools > Extensions and Updates > TypeScript for Microsoft Visual Studio > Disable
Second Workaround:
Rename ServiceHub.Host.Node.x86.exe and if you want to enable it just rename to original file:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\ServiceHub\Hosts\ServiceHub.Host.Node.x86\
Linked:
https://developercommunity.visualstudio.com/content/problem/30326/how-to-avoid-nodeexe-and-servicehubhostnodex86exe.html
https://developercommunity.visualstudio.com/content/problem/31406/visual-studio-2017-nodejs-server-process-turn-off.html
https://developercommunity.visualstudio.com/content/problem/27033/nodejs-server-side-javascript-process-consuming-to.html?childToView=27629#comment-27629
Visual Studio 2017 - Node.JS Server Process - Turn off?
Those errors happened when I was using Visual Studio Installer (after downloading the packages I selected) which was opened through the option to install more project templates (New Project window) in Visual Studio.
I just closed Visual Studio and the conflicts were gone from the Installer allowing the installation to proceed normally.

Is it possible to override Visual Studio 2013 Notification window

Notification window is a new added feature in visual studio 2013. I have an isolated shell application created using visual studio 2013 shell.
Is it possible to extend the Notification window and show notification or information related to our isolated shell application ?
The answer to your question would be yes, however Microsoft does not expose the functionality officially. You can expose these structures yourself, if you're super interested.
The way you can do it, is kind of hackish, but it will work, at least for VS2013. Basically, you need to either reference an internal dll (C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Microsoft.VisualStudio.Shell.UI.Internal.dll), or just copy/paste the relevant structures into your own program, as Kevin has done: User Notifications in the Visual Studio 2013 SDK.
If that is done, you can exploit the interfaces: https://github.com/kevfromireland/visual-studio-2013-notifications-example/blob/master/UserNotificationDemo/UserNotificationDemoPackage.cs
var notificationService = (IVsUserNotificationsService)GetService(
typeof(SVsUserNotificationsService));
var notifcationManager = notificationService.
GetUserNotificationsManagerAsync()
.GetResult();
var vsUserNotificationsManager = (IVsUserNotificationsManager) notifcationManager;
var pic = new RedditPicProvider().GetAwwPicture();
vsUserNotificationsManager.
AddUserNotification(ExampleProvider.Guid,
pic.Url,
pic.Title,
pic.Url,
(uint) NotificationServerity.Critical, isTransient: true);
RegisterNotificationProvider(vsUserNotificationsManager);

Console output in Visual Studio 2010 C++ Like Chrome

I am A PHP Developer, and first time working in Visual Studio C++ and wondering if there is some way through which i can display variables or contents to debug my application.
Is there any functionality like Console in Chrome as console.log(myvariable)?
You could use the TRACE macro.
TRACE( "This is a TRACE statement\n" );

Visual Studio 2010 Log file

I wanna track visual studio activities like projects opened, files opened in visual studio ide and projects build etc. How can i achieve the same?
Start your visual studio IDE using /Log switch.
>devenv /Log c:\log_devenv.xml
To write the user activities into isolated shell of studio use the activitylog service which is exposed by studio. Sample is given below.
IVsActivityLog log = GetService(typeof(SVsActivityLog)) as IVsActivityLog;
if (log == null) return;
int hr = log.LogEntry((UInt32)__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION,this.ToString(),string.Format(CultureInfo.CurrentCulture,"Entering initializer for: {0}", this.ToString()));
For more details use this link How to: Write to the Activity Log

Resources