Created
July 1, 2019 15:14
-
-
Save libbkmz/3d543b3be827d705d603cbead6d16333 to your computer and use it in GitHub Desktop.
Use Visual Studio 2017 com api to attach to running python process with loaded dll for debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os,sys | |
import win32com.client as win32 | |
# import pythoncom as com | |
def attach_visual_studio(): | |
# a = com.GetActiveObject("VisualStudio.DTE.12.0") | |
dte = win32.GetActiveObject("VisualStudio.DTE.15.0") | |
# https://docs.microsoft.com/en-us/dotnet/api/envdte80.dte2?view=visualstudiosdk-2017 | |
# @TODO: check if there more than 1 solution open. | |
# Use corresponsing VS solution instance in that case | |
for x in dte.Debugger.LocalProcesses: | |
if x .ProcessID == os.getpid(): | |
x.Attach() | |
break | |
if __name__ == "__main__": | |
attach_visual_studio() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment