Gokul's Blog


Leave a comment

Macro to attach a process to Debug in Visual Studio

When we have to attach a process for debugging in Visual Studio we have to manually do it by navigating to the Debug menu ==> attach to process.

Here is the code which I tweaked a bit to automate this process.
Reference Url: http://consultingblogs.emc.com/howardvanrooijen/archive/2007/06/24/Attach-to-Web-Server-Macro-for-Visual-Studio.aspx

Code (this enhanced code also supports the Visual Studio built in cassini server)

Public Module AttachProcesstoDebug

    Public Sub AttachToWebServer()

        Dim AspNetWp As String = "aspnet_wp.exe"
        Dim W3WP As String = "w3wp.exe"
        Dim Webdev As String = "webdev.webserver.exe"
        If Not (AttachToProcess(Webdev)) Then
            If Not (AttachToProcess(AspNetWp)) Then
                If Not AttachToProcess(W3WP) Then
                    System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro")
                End If
            End If
        End If
    End Sub

    Public Function AttachToProcess(ByVal ProcessName As String) As Boolean

        Dim Processes As EnvDTE.Processes = DTE.Debugger.LocalProcesses
        Dim Process As EnvDTE.Process
        Dim ProcessFound As Boolean = False

        For Each Process In Processes
            If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1).ToLower() = ProcessName.ToLower()) Then
                Process.Attach()
                ProcessFound = True
            End If
        Next

        AttachToProcess = ProcessFound

    End Function
End Module

Advertisements


Leave a comment

Using Visual Studio “Build Events” scripts to facilitate development

 
Exposing a pipeline component assembly to the Pipeline Designer with Visual Studio requires copying pipeline component assemblies to the Pipeline Components folder. You can automate this task by taking advantage of the Visual Studio “Build Events” functionality. The following steps explain this procedure.
  1. Inside Visual Studio, right-click the pipeline component project, and then select properties.
  2. In the properties window, select “Build Events” from the left-side navigation pane.
  3. Click the “Edit Post-build” button, and then insert the following script in the “Post build event command line” window. If you want to GAC the assembly make sure its signed or else remove the lines (3, 4) part below in the script
   1:  IF $(ConfigurationName) EQU Release GOTO done 
   2:   
   3:  call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" 
   4:  gacutil /if $(TargetPath) /nologo 
   5:   
   6:  xcopy "$(ProjectDir)$(Outdir)$(TargetFileName)" "C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components" /R /Y /F 
   7:   
   8:  IF %ERRORLEVEL% EQU 0 GOTO done 
   9:   
  10:  net stop "BizTalk Service BizTalk Group : BizTalkServerApplication" 
  11:   
  12:  iisreset 
  13:   
  14:  xcopy "$(ProjectDir)$(Outdir)$(TargetFileName)" "C:\Program Files\Microsoft BizTalk Server 2006\Pipeline Components" /R /Y /F 
  15:   
  16:  net start "BizTalk Service BizTalk Group : BizTalkServerApplication" 
  17:   
  18:  :done 
  

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

This removes the need to manually copy the assembly to the “Pipeline Components” folder every time And also stopping and restarting of BizTalk host instances and IIS.

Edit:

With BizTalk Server 2006 Custom Pipeline components can be placed in GAC. Key can be generated using the command  ">sn -k MykeyFilename"

Refer this link for more information: http://geekswithblogs.net/sthomas/archive/2006/09/27/92513.aspx