Is there a way to embed a debugger in a vb.net application? - vb.net

There is a program/service running on different systems executing vb.net scripts.
The application running and managing the scripts is also written in vb.net.
I want to implement the option to debug the scripts directly on the different systems the scripts are running on.
So I am looking for a debugger that can be embedded in a vb.net application.
Ideally the solution would provide code highlighting, Watches, Stepping through the code,
a way to easily add libraries.
A colleague told me there is a way of embedding VS Code in an application, yet I have not found a way to implement the described requirements.

Related

How to control any windows program with no available API

What is the best way to control a program's user interface (clicking, entering text, drop down selection, etc) when the program has no available API?
I've heard of AutoHotKey and FlaUI and watched a few videos but haven't seen a great example yet. Before I go too far, is this the best direction/method?
Thanks!
FlaUI is a fully fledged UI Testing library that allows you to automate all aspects of a Windows application. As author of it, I of course recommend it. If you do have a bit of programming know how, it should be fairly easy to use. In case you just want some scripts to run locally, you don't even need Visual Studio or Visual Studio code, you can just use RoslynPad for example and directly create and run your code there.
I use this all the time for small automations, heck even sometimes to input very long passwords in a remote machine where I cannot use copy/paste.

How can I use a UWP Class Library for scripting?

I have a UWP Class Library project (written in C#) with some useful utility classes and functions. I want to create a script that uses these classes and functions and runs a few times a day automatically. What is the best way to achieve this?
Should I create an app? If so how can I make it run a few times a day?
Should I create a classic console exe program and run it using a script? If yes, can console apps use UWP class libraries?
Should I create a Windows Runtime Component with background task?
Or some other solution?
Assuming that you're definition of "scripting" can be stretched to mean "run an app" there's lots you can do. If you want something that will be seen as a more traditional script then the best you can do is compile the code in a standard .Net class library (not a UWP one) and then call it from a PowerShell script. If you can run apps then there are a few options and the most appropriate will probably depend on the device they're running on, how often you want them to run, and what they actually do.
As you're talking about a UWP app we should allow for it running on different "device families". The easiest way to run on different devices (desktop & phone, etc.) is to have a periodic background task. At time intervals defined by you it will try and run. Subject to connectivity, power, etc.
Because you said a console app was an option then you're probably really only interested in a desktop/PC environment. That's where there's the most options.
Firstly, if your code uses UWP/Win10 specific APIs then compiling into a console app probably isn't possible without changing the code. I do many things like you describe in the question and use console apps for this as I find them the simplest to work with.
If you're going to change code, consider moving to using Portable Class Libraries as you'll then be able to link to that code from many different types of app--including traditional desktop and UWP apps.
I'd avoid creating a runtime component unless you really need to as there are lots of potential gotchas.
You can run any app from the Task Scheduler but launching UWP apps is tricky.
You can launch a regular app or script by setting the action of the task to be the exe. (or the exe and passing the script file as a parameter.)
Apps from the store don't have an EXE you can just launch so you need to do a bit more. They can only be launched by the Windows Shell. But, fortunately, there's a way to do this. Have your task start explorer.exe (You'll find it in C:\Windows) and then add the argument shell:AppsFolder\[app-PFN]!App.
Where [app-PFN] is the Product Family Name of the app. You can find the values of all the installed apps on your machine by looking at "C:\Users[username]\AppData\Local\Packages\"
So, you can use this to launch the store app.
shell:AppsFolder\Microsoft.WindowsStore_8wekyb3d8bbwe!App

Automation testing of application developed using WxWidgets

Is there a possibility to do a automation testing of application developed using WxWidgets on windows platform? If so how do I do that?
wxWidgets uses native widgets so any automated testing solution for Win32 programs would work with wxWidgets applications. However IME the typical "point-and-click" tests are not that great in practice and it's better to write the tests for the GUI code in the same way as you do it for the rest of the program.
There are two problems that need to be solved when doing it though: first, how to trigger various actions in the GUI. This is addressed by wxUIActionSimulator. It is not perfect, but if your application has a reasonable keyboard interface (as it should), it should be enough.
The second problem is related to the control flow in the GUI applications: if some action results in opening of a modal dialog, the test can't continue until the dialog is closed by user, which is inappropriate for unattended tests. wxWidgets provides (still somewhat experimental and not documented yet) wxTEST_DIALOG macro for dealing with this, its use is explained in this comment.
Combination of these two approaches allows to write tests for the real-life GUI applications and, moreover, the tests are portable and not limited to Windows platform.

Programmatically accessing an application through its UI

Earlier I asked a question about command-line parameters to automate processing of a file in InfoPath. I'll probably get the Tumbleweed badge for that one.
Instead of attempting a batch solution through the command line, can someone suggest a good resource for developing a solution that will open an application and then perform actions through the application's user interface like opening a file, printing it, and closing the file?
I've seen a legacy application do this in the past where it would open Attachmate and perform I/O operations through Attachmate's interface - but I never saw the code.
One constraint is that the process will be initiated from an existing .NET solution (i.e. processing 10,000 files). I am also unable to rely on traditional Office macros like those found in Excel - InfoPath does not appear to support them.
One option for automating a GUI based application is to use AutoIT. It will allow you to script the actions that are necessary for clicking menu interfaces, working with dialogs, etc.
Depending on your needs, you can create an AutoIT script on your dev machine, compile it to a standard EXE, and deploy it with the .NET project's compiled artifacts. To pass data to it, either you have your AutoIT script take command line parameters, or you have the .NET solution write a to a file with all the input file parameters and have the AutoIT script read in the file to process it. Based on the number you have in the question, I'd go with the option of writing to a file.
Since you are already on .NET you might want to give the new UI Automation framework a try. I haven't tried it yet, but it is supposed to work with WPF and native Win32 applications.
MSDN also has some samples: UI Automation Control Pattern Samples
Attachmate has a scripting language, an API and all kinds of other stuff to help with automating it. So this may not have been a typical application.
On the other hand, Attachmate products are (IMO) horrible to the extreme and I will go to great lengths to avoid working with them in the first place.

How to create a cross-platform DLL in .net

I have a interesting problem: Where I work we've built a home-grown ERP system in VB6 that we are slowly moving over into vb.net. There are some projects have are in .net: we have a hand-held C# project that uses a web service to talk to our database, I've built some reporting screens using Crystal and some smaller maintenance screens.
Well as we have been plotting the conversion out, we want to have a way to separate our business logic and UI so that the UI can be a win/web form or a Smart Device project. Is this even possible? I try to reference the DLL in a test I have and it gives me this error when trying to debug using a emulator
Deployment and/or registration failed with error: 0x8973190e. Error writing file '%csidl_program_files%\smartdeviceproject1\system.windows.forms.dll'. Error 0x80070070: There is not enough space on the disk.
I'm not sure what it's doing... I take my DLL out and it works fine. Does anyone know of a way I can create a DLL that can target all of these UI without may changes?
This post here
helped me alot. Using a linked projects with conditional complation would seem to work in my case.