Every time I have to go to attach to process, then scroll down and find w3wp.exe
Is there a faster way to do this?
I have a macro for this very purpose. In the tools menu, open up Macros -> Macros IDE. In the lefthand pane, double-click MyModule (or create a new module) and paste in this code:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module MyModule
Sub AttachToIIS()
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(2) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("T-SQL")
dbgeng(1) = trans.Engines.Item("Managed")
Dim proc2 As EnvDTE80.Process2 = _
dbg2.GetProcesses(trans, Environment.MachineName).Item("w3wp.exe")
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
Then, you can edit your keyboard shortcuts and set this to a new combination; I use Ctrl+Shift+A. The command to invoke will be Macros.MyMacros.MyModule.AttachToIIS.
EDITED: changed "COMPUTERNAME" to Environment.MachineName.
You should be able to debug IIS just as if you are using the Visual Studio web server (Cassini):
Show Properties for you ASP.NET project.
Select the Web tab.
In the Servers section select Use Local IIS Web server. Fill in the Project Url.
Run your project in the debugger by hitting F5 (Debug => Start Debugging).
If you are running on Vista or newer with UAC enabled you will have to run Visual Studio as administrator for this to work. Right click on the Visual Studio shortcut and select Run as Administrator.... Accept the prompt to elevate priviledges.
Debug->Attach to Process
Start typing the name of the process "w3wp" and it will immediately find it in the list.
You could write a macro and assign it to a toolbar button.
Related
Let's say there's only one textbox on a page (no confirm button). I have inputted the text. How do I press enter? (in mobile, I can press the "enter" key in the keyboard, but there's no keyboard in visual test).
Can anyone please help me?
EDIT
So in the end I used .NET Script. But I can't integrate the script to Visual Test (the app reinstall itself from the beginning). It works if the scenario fully uses .NET Script, but then I need to change all the Visual Test to .NET Script (I need to make it all in Visual Test or .NET Script).
Does anybody know how to integrate this one function in .NET to Visual Test?
Here's my .NET Script:
Imports SilkTest.Ntf.Mobile
Public Module Main
Dim _desktop As Desktop = Agent.Desktop
Public Sub Main()
Dim map As IDictionary(Of String, Object) = New Dictionary(Of String, Object)()
map.Add("action", "Done")
_desktop.MobileDevice("Device").Invoke("executeScript", "mobile: performEditorAction", New Object() {map})
End Sub
End Module
====== the script's 'till here (I can't insert it into the code brackets) ======
Add a new command that does TypeKeys with an
I found the answer! So in properties pane in the .NET Script click the device name under Application Configurations and add ";noReset=true" in Connection String. Then, uncheck "Execute Base State".
With that, Silk Test will execute the inserted .NET Script in visual test without reinstalling the app.
I'm trying to figure out how to use the Microsoft Online Services Migration Toolkit PowerShell Commands from within an ASP.NET website (using vb.NET).
I've started off using a guide on how to use PowerShell in ASP.NET - from here: http://devinfra-us.blogspot.com/2011/02/using-powershell-20-from-aspnet-part-1.html
I'm trying to work out how to implement the Online Services Migration Toolkit PowerShell cmdlets.
Here is a snippet from my code-behind:
Sub GetUsers()
Dim iss As InitialSessionState = InitialSessionState.CreateDefault()
iss.ImportPSModule(New String() {"MSOnline"})
Using myRunSpace As Runspace = RunspaceFactory.CreateRunspace(iss)
myRunSpace.Open()
' Execute the Get-CsTrustedApplication cmdlet.
Using powershell As System.Management.Automation.PowerShell = System.Management.Automation.PowerShell.Create()
powershell.Runspace = myRunSpace
Dim connect As New Command("Get-MSOnlineUser -Enabled")
Dim secureString As New System.Security.SecureString()
Dim myPassword As String = "ThePassword"
For Each c As Char In myPassword
secureString.AppendChar(c)
Next
connect.Parameters.Add("Credential", New PSCredential("admin#thedomain.apac.microsoftonline.com", secureString))
powershell.Commands.AddCommand(connect)
Dim results As Collection(Of PSObject) = Nothing
Dim errors As Collection(Of ErrorRecord) = Nothing
results = powershell.Invoke()
errors = powershell.Streams.[Error].ReadAll()
For Each obj As PSObject In results
Response.Write(obj.Properties("Identity").Value.ToString())
Next
End Using
End Using
End Sub
When I try to run the code via the page, I'm getting the following error
The term 'Get-MSOnlineUser -Enabled' is not recognized as the name of
a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path
is correct and try again.
So I'm guessing I haven't worked out how to import the Online Services Migration Toolkit PowerShell CmdLets. I'm also not exactly sure if the line:
iss.ImportPSModule(New String() {"MSOnline"})
Is exactly correct. Is there a way I can verify the Module name?
I'm also unsure of where and how to reference the .dll files. At the moment I have copied them to my bin folder but I can't add them as references, so how does the ImportPSModule statement know where to find them? Especially when the website is published to the final production server.
One other question, should I be using the x86 or x64 cmdlets? I'm developing on Win7 x64, but not sure if the website builds as x86 or x64? Do I need to find out what architecture the server is?
"Get-MSOnlineUser -Enabled" is not a command; "Get-MSOnlineUser" is. I'm a bit confused how you got it correct further down the script with connect.Parameters.Add("Credential", ...) but didn't do the same thing for -Enabled.
Use connect.AddArgument("Enabled") or connect.Parameters.Add("Enabled", true) and you should be good to go.
Is anyone aware of a Visual Studio 2010 Add-In that will automatically allow you to attach to a running instance of the ASP.Net Development Server? And if there is more than one currently running, display a quick dialog that lets you choose from a list of just the ASP.Net Development Servers that are running?
Why do I want this? <-- feel free to skip this part.
The way I usually develop / debug web applications is to launch a browser and navigate through the application until I get to the page I want (could be many pages deep.) I don't want to have the debugger attached through these steps for various reasons (it is slower than not having it attached, extraneous break-points may be hit, I may have break when "thrown" turned on and not want to break earlier in the app when handled errors are thrown, etc...)
I navigate to the page I want, then use the Visual Studio menus to Debug > Attach to Process, and then from within the Attach to Process dialog, I have to scroll all the way down (pages and pages and pages of processes) until I find the WebDev.WebServer40.EXE process I want and choose that.
Doing this makes me take my hands off the keyboard and use a mouse (something I generally try to avoid.)
And doing this seems needlessly repetitive since, if I am debugging an ASP.Net Web Application, I always want to attach to an instance of the WebDev.WebServer40.exe.
I prefer to do the exact same thing and it IS possible to bind it all to a keystroke with a macro.
Goto Tools > Macros > Macro IDE
Add a new module and use this code (the funky comments are for syntax highlighting)
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Collections.Generic
Public Module AttachingModule
Sub AttachToAspNET()
Try
Dim process As EnvDTE.Process
Dim listProcess As New List(Of String)
'' // uncomment the processes that you'd like to attach to. I only attach to cassini
'' // listProcess.Add("aspnet_wp.exe")
'' // listProcess.Add("w3wp.exe")
listProcess.Add("webdev.webserver")
For Each process In DTE.Debugger.LocalProcesses
For Each procname As String In listProcess
If process.Name.ToLower.IndexOf(procname) <> -1 Then
process.Attach()
End If
Next
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
Click on File > Close and return
Click on Tools > Options
Click on Environment > Keyboard
I put the macro in MyMacros, so I look for "Macros.MyMacros.AttachingModule.AttachToAspNET" in the "Show Commands Containing" textbox".
I prefer to use Ctrl+Alt+D but put whatever you want in the "Press Shortcut Keys" textbox and click Assign, then OK
Now all you have to do is hit Ctrl+Alt+D to attach to all cassini instances.
I've seen various versions of this around the internets and this was the most recent I found. I had to modify that slightly to remove the extra web processes and to drop the .exe from WebDev.WebServer.exe, so that it would debug .net 4.0 instances of cassini.
I don't know of any such add-in but you can more easily attach to the process using shortcut keys and pressing 'W' to scroll to the WebDev process.
Ctrl+Alt+P - Attach to Process
(process window now has focus)
Press W, which jumps to processes starting with W
Press Enter to attach
Not an addin but you can do it without touching the mouse.
Check this answer out: Attach To Process in 2012
This is a simple plugin that gives shortcuts to attaching to nunit agent, IIS and IIS Express. Its pure convenience as compared to Ctrl-Alt-P, but it is convenient.
Direct link to the plugin here
I'm debugging an ASP.NET application deployed on IIS 7.5 (VS 2010/Windows 7 x64) . After I make changes, I have to deploy it to the IIS folder and then do the following things (anyone of you should already know, I just list to demonstrate how boring and time-consuming they are):
Click on the Debug menu, choose Attach to Process
From the list, choose Show processes in all sessions
Choose the right w3wp.exe process
Click attach
Click attach again
well, it's load of unnecessary works. Due to our system architect, this is the only way, we can debug straightforward by F5 button, but I wonder that if there's a workaround about this, so I can do all these things in on-click or short-cut key.
Thank you very much.
http://blog.lavablast.com/post/2008/01/11/Attach-to-Process-with-one-shortcut.aspx
Create a macro in visual studio with the following:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports System.Security.Principal
Public Module RecordingModule
Sub AttachToAspNET()
Try
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("w3wp.exe")
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
End Module
change w3wp.exe to aspnet if thats what you want. Then go into the key shortcuts and just bind a shortcut to run that macro.
Why don't you just go to project properties and select Use Local IIS Web Server.
If this is remote server you can do this too: Using Visual Studio 2008 with IIS 7
Although the article is about VS2008, the concept is the same in 2010.
We have a silverlight ASP .NET web application which needs to be deployed on client's server along with Sql Server database. Once they deploy on their server, many workstation can access it and run silverlight client.
I was thinking to create a small deployment project, add necessary script files to the resources, and create an msi Once after installation is completed, we can execute the sql scripts to add database and its tables. I am not sure if this is feasible, is there a better way of doing it? Also, if there are any future updates to the app / db, how can it be done on the server (silent update/install)?
Any links / steps / procedure is highly appreciated.
Thanks!
You can create the scripts using the MSI, and then you should be able to run them as part of the installation using sqlcmd or osql command line utility, you'll obviously need to let the user capture server name, db name and credentials as part of the install.
With updates to the db schema, you can do it through code in your application, which means you'll need to maintain a database version somewhere for the app to know when to run the script, or just script the relevant alter statements, and run it on the server as part of deployment, once again using one of the command line utilities.
Thanks for the reply Baldy. This is exactly what I thought and did a small test. I have a simple ASP .NET web application with one label, one class library project which has an overrides method Install (creates a batch file and executes it), wand a WebSetup project which actually installs and during installation it will execute the Install method from class library project. Here's the code -
1) ClassLibrary Project - MyCustomAction
<RunInstaller(True)> _
Public Class SetupAction
Inherits Installer
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
MyBase.Install(stateSaver)
Try
My.Computer.FileSystem.WriteAllText("E:\SetupTest.txt", Environment.NewLine + "File created from MyCustomAction project", True)
'Shell("SQLCMD -S Dev1 -d Prac -i ""E:\Copy of CreateTable1.sql""", AppWinStyle.MinimizedFocus, True, 5000)
File.WriteAllText("E:\Test.bat", "SQLCMD -S Dev1 -d Prac -i ""E:\CreateTable1.sql""")
Process.Start("E:\Test.bat")
Catch ex As Exception
My.Computer.FileSystem.WriteAllText("E:\ErrorLog.txt", Environment.NewLine + "Exception: " + ex.Message, True)
Finally
End Try
End Sub
End Class
2) ASP .NET Project - MyApplication
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = "Current Time: " + Now.ToString
End Sub
End Class
3) WebSetup Project - MyApplicationSetup
I have added the project output from the above projects to it
I have added a new "Tnstall" CustomAction referencing it to the output of MyCustomAction class library project
When I build the msi installer and install the Web Setup application it intalls (copies the output files), and also creates SetupTest.txt, Test.bat files but it neither executes the Shell command line statement nor Process.Start() successfully.
Once the bat file is created, if I manually double click it does execute the sql Script file.
As a side note, if I run CustomAction code in a separate Windows App, it executes perfectly fine. So, looks like while installation, its not able to execute the command line commands (though I do see cmd.exe / SQLCMD.exe in the task manager). I am not sure if this would be a permission issue, but I am in the admin group and have necessary permissions.
It may not be appropriate to write these comments in "My Answer" section, but wanted to give a detailed explanation of the situation. I am really stuck with this and would be very helpful if anyone can throw pointers on improving / alternate methods. Thanks in advance and really appreciate the help.