كيف يمكنني جعل Visual Studio الكلية إرفاق مصحح الأخطاء في كل الحالات w3wp.exe?
-
03-07-2019 - |
سؤال
أنا عادة تطوير تطبيقات الويب و كمية كبيرة من المستغرب من عملي في الوقت يقضى في "Ctrl + Alt + P" فرز حسب اسم العملية ، واختيار w3wp.exe إرفاق بلدي المصحح.
لجعل الأمور أسوأ, أنا أعمل على التطبيق الذي يمتد عدة تجمعات التطبيقات لذا عادة ما يكون 2 أو 3 حالات w3wp.exe و من المستحيل أن تعرف أي واحد إرفاق لذا عادة في نهاية المطاف ربط كل منهم ، وهو مبالغة ولكن يعمل.
جميع في كل هذا هو مزعج جدا...
زميلي اكتشفت طريقة أن يكون مقابل الماكرو تلقائيا إرفاق w3wp.exe (هو في الأساس سجلت هذا):
Sub AttachMacro()
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(3) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("T-SQL")
dbgeng(1) = trans.Engines.Item("T-SQL")
dbgeng(2) = trans.Engines.Item("Managed")
Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "ENIAC").Item("w3wp.exe")
proc2.Attach2(dbgeng)
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
أنا لست متأكدا ما إذا كان كل ما هو ضروري ، أو أي شيء ، لم يسبق لي أن قدمت ماكرو VS, أنا حقا لا أعرف من أين تبدأ.
هل هناك طريقة لتعديل هذا الماكرو بحيث بدلا من إرفاق نفسها إلى وهو مثيل w3wp.exe ، وسوف نعلق نفسها كل حالات w3wp.exe?
المحلول
Sub MacroAttachToAllProcesses()
Try
Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
Dim dbgeng(3) As EnvDTE80.Engine
dbgeng(0) = trans.Engines.Item("T-SQL")
dbgeng(1) = trans.Engines.Item("T-SQL")
dbgeng(2) = trans.Engines.Item("Managed")
For Each theProcess As EnvDTE80.Process2 In dbg2.GetProcesses(trans, "COMPUTERNAME")
If theProcess.Name.Contains("w3wp.exe") Then
theProcess.Attach2(dbgeng)
End If
Next
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
نصائح أخرى
وأنا أعلم أن كنت تبحث عن الكلي لهذه المهمة و علي غرار وحدات الماكرو.ومع ذلك أود أن أشرح طريقة إرفاق مصحح الأخطاء المشاريع في الحل الخاص بك عند بدء التصحيح.
انها سمة معروفة - إذا كنت انقر بزر الماوس الأيمن على ملف الحل في الحل المتصفح ، اختر خصائص ثم يمكنك تحديد عدة مشاريع بدء التشغيل و العمل.مصحح الأخطاء سوف نعلق على المشاريع المدرجة عند تشغيله.
ملاحظة:إذا كان لديك خدمة الويب فإنه سيتم فتح نافذة المتصفح ، ومع ذلك يمكنك تعطيل هذا في خصائص المشروع بقوله أنه لا لفتح نافذة.
هذا هو كيف لي أن نعلق على بعد w3wp العملية.أنه يعمل بشكل أسرع قليلا من DanC الحل وبعض إضافية معالجة الخطأ.
Private Sub AttachToW3wp(ByVal machineName As String)
' In order for this to work, you have to be running the Visual Studio 2010 Remote Debugging Monitor
' as your (domain) user.
' It won't work if the remote debugger is running as a service. I've tried every permutation of
' domain and username in the the transport qualifier, tried the obvious local system username,
' even tried looking at the network traffic
' in WireShark, I can't figure it out how to make it work if you are running as a service.
' If you are running the debugger as a service, even running the macro that gets created by VS's
' macro recorder when you attach to a process doesn't work.
Dim transportQualifier = machineName
Try
Dim processToAttachTo As String = "w3wp.exe"
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 (v2.0, v1.1, v1.0)")
Dim processesRemote = dbg2.GetProcesses(trans, transportQualifier)
Dim attached As Boolean = False
Dim processRemote As EnvDTE80.Process2
For Each processRemote In processesRemote
' For some reason it takes a much longer time to get the remote process names then it
' does the user name, so let's skip over all the processes that have the wrong UserName.
If processRemote.UserName = "NETWORK SERVICE" AndAlso _
(Right(processRemote.Name, Len(processToAttachTo)) = processToAttachTo) Then
If processRemote.IsBeingDebugged Then
MsgBox(processToAttachTo & " on " & machineName & " is already being debugged")
Else
processRemote.Attach2(dbgeng)
End If
attached = True
End If
Next
If Not attached Then
MsgBox(processToAttachTo & " is not running on " & machineName & ".")
End If
Catch ex As System.Exception
MsgBox("Exception attempting to attach to " & transportQualifier & ": " & ex.Message)
End Try
End Sub
قد ترغب في التحقق gflags.exe.أحد الخيارات هو المصحح تشغيل تعلق كل احتجاج معين قابل للتنفيذ.