Programmatically monitoring which tab is opened in visual studio - c#

Let's start with an example, User have several tabs opened for a solution>project in Visual Studio (Default.aspx, Default.aspx.cs) I programmatically want to monitor devenv.exe process and want to know which tab (file to be exact) user is working on. If there's some log file or process object has some attribute that tells? Or it has to be done with image processing?

You can write an extension for Visual Studio and monitor DTE.Events.WindowEvents.WindowActivated. From an active window you can get Document.FullName for a file user is working on.
See for example Display document path of the active window in the status bar.

Related

Cannot upload file to D365 in headless mode Selenium C#

I have a set of Dynamics 365 automated tests which run fine whilst the browser window is open on the screen, but when I run the tests in headless mode, all of them fail when trying to upload a document.
This is my current code for uploading the file:
PaperClipButton().Click(); // this clicks the paperclip icon to open the file upload window
Driver.SwitchTo().ActiveElement();
SendKeys.SendWait(#$"{rootDirectory}\MyFile.pdf");
SendKeys.SendWait(#"{Enter}");
When running in headless mode it inputs the string that is supposed to go into the file upload window inside the Visual Studio window when I'm debugging the test and not in the browser where it's supposed to go.
I've checked the failure screenshot and it doesn't open the file upload window at all and fails on the step where it checks the file has been uploaded.
Also tried removing the line for SwitchTo().ActiveElement() but get the same result
Has anyone had similar issues with D365 automation?
Thanks in advance
I recommend to put the file in your solution and do paperclipElement.sendKeys the path.
Once you click on paperclip, I am guessing file explorer will open up, Selenium cannot control OS applications.

C# code works but errors occur while packaging my UWP application in Visual Studio 2017

I have created a UWP application in Visual Studio. I plan on using it only for side loading(it is a LOB app). It doesn't have any errors. But when I try to package it, I get the following errors.
Errors in Packaging
0X8007000b an attempt was made to load a program with an incorrect format
Also, here is my output console.
How do I fix this?
From the solution explorer, double click and open Package.appxmanifest
Click on Visual Assets tab on top. It is second from left, after Application tab.
Select a source image (this is the image you want to use for logos, badges, splash screen, etc.)
Under assets combo box, select all All Visual Assets
Hit Generate
Say ok that it will overwrite your existing files
Now, if you want to use a different image for any of the specific areas, for example, App Icon, scroll down, and provide a different source for it.
Now, build and make sure your app builds. Then attempt to create the app package again.

How to get Xamarin Studio C# output within the IDE?

I recently started experimenting with Xamarin and Mono C# on my Mac. I am used to working on Windows with Visual Studio so I find it cumbersome when every time I run my console application, a new terminal window and mono compiler terminal open up. And I have to manually close them. Is there anyway to get the output of my programs from a window or pane inside the IDE ? Or is there anyway to set it up so only one terminal window shows up ?
If you open the Project Options there is a Run on external console check box in the Run - General category which controls this behaviour. If you uncheck this option when you run a console application the output will be shown in an Application Output window inside Xamarin Studio and no external console window will be opened.
For anyone else arriving at this question who can't locate 'Project Options', the item is found in a drop down menu under the Project Tab (located at the top of the screen on the app's main nav bar). When a solution/file is loaded, the item is listed with your project's actual name, ex: 'MyProject Options' or 'MyProject&Options' (–it does not literally read 'Project Options').

C# custom action windows form focused issue

Background:
I used Visual Studio setup project to deploy one of C# application to client windows server.
While installing the application I need to setup a scheduled task in the server as well
For this I used a Custom Action feature in the setup project. What I did is created a windows form with input fields and "ok" button and once user enter values and click on the "ok" button task will be created. I added this custom task in Install and Commit steps in Custom Action.
Issue
: Everything works fine but when the created windows from shows, it lost the focuses even I used showDialog method to show the form. So always main setup window will active and users not see the popup form in background (see the attached image).But I can click on the popup window and make it activate. I tried with SetActiveWindow method also but no good result so far.
Simple what I need is to activate the popup window untill user action (default showDialog behavior). So here I'm looking for any help.
If you want to get user input using custom UI during the MSI deployment best approach is to create the .wid extension files. this is the type of UI files that you see during the MSI installation(where you select the installation path etc). Enough though visual studio doesn't have features to create these UI files there are Microsoft tools you can use to create these files. One of the best tool is Orac.
Orac.exe
How to use the Orca database editor to edit Windows Installer files
Once you create the UI file, you have to place the file under C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\Deployment\VsdDialogs\1033 (it's where MSI picks the default UI files from)
After that you should be able to select your custom UI and inject it during any phase of installation cycle(beforeinstall, install, afterinstall etc). Then you can pass the value user has entered into the text field as a argument for installer class. Then you can read the value within the installer class using context parameter.
string value = Context.Parameters["ParameterName"];

Program to obtain code file for active window

I have Process Explorer v15.13. It works OK. I can tell which process an active window belongs to. On the other hand, the PE debugger says its not compatible with VS 2010 (Or at least team explorer 2010 MSSCCI).
I would like to be able to pinpoint the .cs designer code related to the active winform. Is this possible to do with any program?
Process Explorer should tell you the name of the form. Decompile the app using (dotPeek) and search for the name. All the designer code will be there for your viewing pleasure.

Categories