Why have my Visual Studio 2008 SP1 macros stropped working - visual-studio

I just cannot for the life of me figure out why my build event macro is no longer firing. Any ideas?
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module EnvironmentEvents
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, _
ByVal ProjectConfig As String, _
ByVal Platform As String, _
ByVal SolutionConfig As String, _
ByVal Success As Boolean) _
Handles BuildEvents.OnBuildProjConfigDone
If Success = False Then
'The build failed...cancel any further builds.
DTE.ExecuteCommand("Build.Cancel")
End If
End Sub
End Module

Have you tried running Windows Update? Are all the macros not working or just this one?

Related

I'm loading a .DLL in runtime, but always i stop the solution in debug mode and start again the program will crash

I'm using a device in my vb6 program and i loaded the .dll of this device during runtime in a module.
I need to declare all the methods of the .dll
Example:
Declare Function FTRGetParam Lib "FtrAPI.DLL" _
(ByVal Param As Long, ByRef value As Any) As Integer
But when i enter in this module again in the next execution, the program will crash and i must to close the Visual Studio IDE.
Any Idea?

New exe icon not reflecting in windows 7 task bar for vb6

I changed the resource file for a new icon for my exe and generated the exe for vb6 project. However, the exe icon has changed but the windows 7 task bar is still showing the old icon.
If I generate the exe in some other location other than my project directory its working fine. Could someone please help on this issue?
You need to tell Windows you updated the icon so it can update its cache.
If you're using VB6, make yourself a little utility:
Create a new EXE project (name it "ForceIconsRefresh" or something like that)
In the project properties, change the Startup Object to "Sub Main"
Add a new module, remove the default Form object
In the module add the following:
Option Explicit
Private Declare Function SHChangeNotify Lib "Shell32.dll" (ByVal wEventID As Long, ByVal uFlags As Long, ByVal dwItem1 As Long, ByVal dwItem2 As Long) As Long
Private Const SHCNE_ASSOCCHANGED As Long = &H8000000
Private Const SHCNF_FLUSHNOWAIT As Long = &H2000
Sub Main()
Call SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, 0, 0)
End Sub
Compile
Execute after building an EXE with an updated icon
VoilĂ !

get the text of edit box from other program

I'm not sure how to get text of edit box from other application using visual basic. In C++ I just find the handle of edit box with FindWindow and FindWindowEx, ... using WIN API. How to do this in visual basic ?
For VB6 just use FindWindow and FindWindowEx... using WIN API.
you'll need the proper declares at the top:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Look at the PInvoke site for the correct syntax for whatever flavor of VB you are using
The real trick is that the V6B controls use to different class names than you might be used to.

Visual Studio 2008 BuildEvent Macros not Firing

I added this well documented macro to MyMacros, Environment Events in VS 2008 Macros in order to cancel failed builds:
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone
If Success = False Then
'The build failed...cancel any further builds.
DTE.ExecuteCommand("Build.Cancel")
End If
But it's not canceling my builds. I also set breakpoints to hopefully catch it firing but they are not hit either.
I also added this test macro but its not being fired either:
Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
Beep()
Beep()
End Sub
The "Allow macros to run" option is set.
Why is it not being fired? Why are my breakponts not being hit?
Thanks for your help
Apparently you have to run Debug (green play button) in the Macros IDE for breakpoints to be hit.
Now I know.

Visual Studio 2008 macro only works from the Macro IDE, not the Macro Explorer

Edit: Creating a new module in the same VSMacros project fixed the problem.
The following macro only works if I open the Macro IDE from Visual Studio and run the macro from there.
It'd be much more useful if I could just right click the macro from the Macro Explorer from my Visual Studio instance.
I must be doing something obviously wrong, but I've never worked with VS macros before. The MessageBox does not appear in either case.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal
Imports System.Windows.Forms
Public Module AttachToSdtProcess
Sub AttachToSdtProcess()
Try
'If MessageBox.Show("Attach to SDT.exe", "Caption", _
' MessageBoxButtons.OKCancel) = DialogResult.Cancel Then
'Return
'End If
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim compName As String = WindowsIdentity.GetCurrent().Name
compName = compName.Substring(0, compName.IndexOf("\"))
Dim proc2 As EnvDTE80.Process2 = _
dbg2.GetProcesses(trans, compName).Item("TheExecutable.exe")
If proc2 Is Nothing Then
MessageBox.Show("Could not find TheExecutable.exe")
End If
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
From this article on MSDN I think I found the another possible answer. The main suggestion of that thread was to:
In the Tools, Options menu, Add-Ins/Macros security section, check the checkbox "Allow macros to run"
The messagebox in the macro editor is :
MsgBox("Your Text Here") = Resultxx
Good Luck.

Resources