I'm building a Visual Basic application in Visual Studio 2010. Some of my options can only be applied on restarting the application.
I have not gotten a single crash when application is running normally. Nor does it crash when I apply settings, manually exit and restart. On the other hand, as soon as I try to do a automatic restart from the application, I get an exception on one out of 5-10 restarts.
I've tried to run the debugger, but as soon as the application restarts, the Visual Studio debugger is turned off and does not turn back on when the application launches again. Nor does it launch again with same configurations. It seems the debugger launched application configuration and the manually launched application configuration files are different.
Is there a way I can get around this? Keep the debugger on across restarts? Or should I undertake a different strategy?
Method 1: Attaching the debugger from within the application
If the application sometimes crashes at startup add a call to Debugger.Launch() in the application's Startup event. Doing so will cause Visual Studio to open a window where you can choose to attach its debugger.
You can check the Debugger.IsAttached property in order to determine whether a debugger is already attached or not.
Steps to subscribe to the Startup event:
Right-click your project in the Solution Explorer and press Properties.
Go to the Application tab.
Press View Application Events.
Select MyApplication (events) in the left combo box.
Select Startup in the right combo box.
Code:
Imports System.Diagnostics
...
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
If Debugger.IsAttached = False Then
Debugger.Launch()
End If
End Sub
Method 2: Letting Windows start the debugger, which in turn starts your application
An alternative solution is to add your application to the Image File Execution Options registry key, which allows you to specify a debugger which should launch the application for you.
NOTE: Adding your application to Image File Execution Options causes Windows to automatically launch the specified debugger instead of your application whenever you try to open it. Your application's path is passed as a command line argument and it is then up to the debugger to launch your application, attaching itself to it.
Malwarebytes have some info about Image File Execution Options on their blog: An introduction to Image File Execution Options.
Here's how you'd do it:
Open Regedit.
Navigate to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options key.
Locate the key with the name of your application (if it exists), or create a new one in the format of yourApplicationName.exe.
Create a new String value (REG_SZ) and name it debugger.
Set the value of debugger to vsjitdebugger.exe.
Go ahead and start debugging!
For more information see: How to: Launch the Debugger Automatically - MSDN
Related
Introduction
I've looked around and haven't seen anyone else having my issue.
Basically, I am wanting to run a start.bat file to start up my server before I start up my debugging session. I currently have my debugging inside of an IntelliJ Configuration and it works well. The problem is that in the options for my configuration I can't seem to add an "External Tools" task to the Before Launch section. I was able to add a maven task here previously. However, when I follow the following steps, the "start.bat" is not added.
First I go into Settings->Tools->External Tools to add my Spigot-Server tool which basically calls the start.bat file inside of a test-server directory.
Snippet of External Tools
Second, I go into my "Debug Spigot" configuration and at the bottom, I see a "Before Launch" Section.
Snippet of Spigot Debug options
I click on the + inside of that section to add a new task, and I click on "External Tools"
Snippet of adding External Tools Task
And then I make sure my Spigot-Server task is selected.
Snippet of select external tool
And then once I hit okay, the window closes but I don't see a new task added to the before launch section. It looks the same it did before I clicked on anything. I also don't see any status message at the bottom of IntelliJ
I basically expect the task "Spigot-Server" to show under the Before Launch section. This would basically start up the server and once the server was completely started, it would then launch the debugging configuration.
I think it may be an issue with IntelliJ's UI. I searched IntelliJ's issue tracker But couldn't find any that matched.
I'm wanting to know if there are any work arounds to get this setup in IntelliJ>
I was able to achieve my goal by doing some workarounds that I discovered with the help of CrazyCoder. I found this stackoverflow question that told me about the batch plugin.
I was able to create a Batch run configuration for a wrapper batch file that gets around the limitation CrazyCoder mentioned. He said that even if I did get my setup where my server runs before my debugging is launched, my debugging would never launch. This is because the terminal process needs to exit before the next task starts.
To get around this this is the wrapper batch file I created.
#echo OFF
START "Spigot-Server" /D C:\Users\rocke\Documents\Programming\Minecraft\Spigot\capture-the-carrot\test-server "start.bat"
ping -n 3 127.0.0.1 >nul
It basically uses the "START" command to run the task asynchronously and then waits 2 seconds. This is because all I need to do is wait for the start.bat command to run the very first part so that it establishes remote debugging. And then the wrapper ends after 2 seconds (the 3 represents the number of seconds I want to wait +1). And this allows the Debugging process to start while also ensuring that the server has setup remote debugging!
I'll just share screenshots of my configuration if anyone wants to do the same.
Maven Build Configuration
Spigot Server Start Configuration
Remote Debugging Configuration
The way this is setup is once I run the Remote Debugging Configuration, it has a "Before Launch" Task of Spigot Server. Spigot Server also has a "Before Launch" Task of Maven Build Project.
So my Maven Build Project runs, then my Spigot Server wrapper runs and after 2 seconds terminates, and then my Debugging Configuration runs!
If you have any questions regarding remote debugging with spigot, use this resource: https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
I have configured a Windows 7 VM as an agent to my TFS2015 setup.
I have created a Gradle (invoking the gradlew.bat) job to run my selenium scripts from the TFS build definition as
gradlew.bat clean test aggregate
This works fine (I can see IE being invoked) when I run it MANUALLY from the VM directly, BUT when the same is triggered as a job, it runs only in the background. Here are my observations:
The processes - Java, iexplorer, IEDriver.exe are all getting invoked in the Process manager.
When I kill iexplorer process, I can see the UnreachableBrowserException on the TFS console and the next test case runs.
The job with 2 test cases (approx 3-4 mins) fail after running for 10 mins and I see the error logs in TFS console
The scripts ran on UI the very first time I set this up but has never run after that.
I am using Gradle 3.0 and have disabled the Gradle Daemon by adding org.gradle.daemon=false in gradle.properties. This has been bugging me for a couple of days so badly.
Any help would be great.
For your tests to interact with the desktop they will need to be running interactively on a machine that is logged on and not locked (no screensaver active).
See: https://www.visualstudio.com/en-us/docs/build/admin/agents/v2-windows#interactive
You can configure the machine to start-up automatically and authenticate on start-up, disable the scren locking policy and screensavers and add the run.cmd to the windows start-up section in the star-menu.
See: http://donovanbrown.com/post/2015/08/28/auto-start-build-agent-in-interactive-mode
Press Windows Key + R to open the Run dialog
Type in the following and press enter:
control userpasswords2
Uncheck the box for User must enter a user name and password to use this computer.
Click the Apply button
You will be prompted by an Automatically sign in dialog
Enter the password for the user
Click OK
Click OK on the Users Accounts dialog
And
Right-click the desktop
Select New / Shortcut
Enter cmd
Click Next
Change the name to Start Agent
Click Finish
Right-click on the new shortcut
Select Properties
Append /c {pathTo\run.cmd} to the target
If you installed your agent to C:\Agent, your target should look like this: C:\Windows\System32\cmd.exe /c c:\agent\agent\run.cmd
Click OK
Note: updated for the 2.0 build agent, which is started using run.cmd instead of vsoagent.exe
Press Windows Key + R to open the Run dialog
Type in the following
shell:startup
Click OK
This will open the Startup folder in Windows Explorer.
Drag and drop the shortcut to this folder
I'm using Visual Studio Professional 2013 and I'm doing some very basic windows forms application.
A month ago, I could do everything I wanted without any problem. But I started some new projects today and for absolutely no reasons, I keep getting this error message when I come to debug or compile:
Debug error BC31019 : Unable to write to output file 'path/form.exe System Error &H80070005&
It can happen simply by changing the size of a textbox or modifying the text content in a label... It's very random... And I can even do an undo (ctrl+z) and then I can debug again, but if I try again to do the thing I did that brought the error message, the same message pops again as I try to run.
After reading a little about the subject, I realized that it was because the .exe file became in read-only mode and when I try to remove it, windows wont let me.
The only thing I can do if I really want to continue, is to restart my computer every times it happens. Then I can continue just like normal as my .exe file is no longer in read-only...
I tried tor run a sfc/scannow in my command prompt to see if i had any problems with my frameworks but everything was fine.
Since, it is when i restart my pc that the bug disapears, isn't anything i can do or run somewhere to do the same thing. I need to find why the exe file goes to read-only for nothing and how to get it back to normal without having to restart my pc every time...
Please help me!
thank you
I came across the same issue and it was related to having a command line argument that VS could not find, then when i clicked stop debugging I ended up in this situation as it seemed VS kept a process running.
I could see this process in task manager but could not end it (it started with the same name as my app)
I found closing VS would release this process.
Restarting VS it would then work ok again.
there may be other ways to reproduce the issue but restarting VS seems to release the file and allow you to continue.
I set the exe properties to Read/write. No effect, but when I set app properties/settings to "Always on top" = False the issue went away and is still away.
I have a strange problem using vb.net (vs2010) and SQLite database: I made an install package with Setup and Deployment project, everything seems to be working fine. My SQLite databse installs under CommonApplicationData folder and the software under ProgramFiles\ProductName. In the setup project I set a custom action, the user have a choice to run software after install:
/StartApp="[CHECK]"
Private Sub MyInstaller_Committed(ByVal sender As Object, ByVal e As InstallEventArgs)
Dim productName As String = Context.Parameters("ProductName")
StartAfterInstall = Me.Context.Parameters.Item("StartApp")
If StartAfterInstall = "1" Then
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
Shell(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\FB.exe")
End If
End Sub
In ApplicationEvents.vb I set at StartUp:
AppDomain.CurrentDomain.SetData("DataDirectory", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
And here comes the strange behaviour: if the user starts application after install, the program connects to another(?) database, not to installed under CommonApplicationData. If the user inserts data, seems everything working fine.
After closing the application and starting new from the desktop/programfiles/users program menu connects the program to the database installed under CommonApplicationData, but he can't see the changes he made launching application after installation. So starting program from desktop/programfiles/users program menu => everything fine, but the first (automatic) start after install is a problem. I can't find out what happens, any ideas?
Has your Installation Administrator-Privileges?
If yes, the following probably happens:
you are writing to ProgramFiles. Windows redirects this to the administrator %appdata%\roaming folder because writing to ProgramFiles is considered bad.
It goes to the administrator account because the installation had administrator-privileges.
When you start your program from the user account, the user-specific %appdata% Folder is used, which is empty.
Do solve that problem:
do not launch your program from the installer.
Create a directory for your program in %appdata% and usw it.
I'm trying to run some VBSCRIPT from within my application. This works fine when I run my program from within VB. But once I add "UIAccess=true" to my manifest and digitally sign my exe with my certificate, I am unable to run the code any more. It gives errors when I try to interface with any program saying "429: ActiveX component can't create object: 'myApp.Application'". Anyone have any idea why it would run fine in the IDE but not with an application with uses UIAccess? Here is the code:
Dim scriptRunner As New MSScriptControl.ScriptControlClass
scriptRunner.Language = "VBScript"
scriptRunner.AllowUI = True
scriptRunner.Timeout = 3000
scriptRunner.AddCode(scriptStr)
scriptRunner = Nothing
In googling around, I found this website.
it says
Applications with the uiAccess flag set to true must be Authenticode signed to start properly. In addition, the application must reside in a protected location in the file system. \Program Files\ and \windows\system32\ are currently the two allowable protected locations.
maybe it works in your IDE because your IDE is within \program Files\, but outside of your IDE you are running the signed application NOT within \program files or \windows\system32