我正在尝试在我的 web api 站点上设置 MiniProfiler,并且很难MiniProfiler.Current
开始工作。
我按照 miniprofiler.com 上的指示,在 global.asax 中有以下内容:
protected void Application_Start()
{
MiniProfilerEF6.Initialize();
// other setup
}
protected void Application_BeginRequest() {
// need to start one here in order to render out the UI
MiniProfiler.Start();
}
protected void Application_EndRequest() {
MiniProfiler.Stop();
}
Run Code Online (Sandbox Code Playgroud)
这使用默认的WebRequestProfilerProvider,它将实际的配置文件对象存储在HttpContext.Current.Items
.
当我要求时MiniProfiler.Current
,它看起来像HttpContext.Current
。
当我请求我的 Web api URL 之一时:
Application_BeginRequest
创建分析器,将其存储在 HttpContext.Current
MessageHandler
,我可以看到HttpContext.Current
IActionFilter
,HttpContext.Current
现在为空,我的尝试MiniProfiler.Current.Step("controller:action")
失败了 …我试图从python中调用WindowsInstaller.Installer.ProductsEx,并且无法弄清楚如何使其工作.
这是我想从python调用的vbscript版本:
dim msi, products
set msi = CreateObject("WindowsInstaller.Installer")
set products = msi.ProductsEx("", "s-1-1-0", 7)
Run Code Online (Sandbox Code Playgroud)
我认为我的问题是ProductsEx
一个带有3个参数的只读get属性,我不知道如何说服win32com
或comtypes
以这种方式调用它.
我试过了:
>>> import win32com.client
>>> msi = win32com.client.Dispatch('WindowsInstaller.Installer')
>>> products = msi.ProductsEx('', 's-1-1-0', 7)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<COMObject WindowsInstaller.Installer>", line 2, in ProductsEx
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
Run Code Online (Sandbox Code Playgroud)
和类似的使用comtypes
:
>>> import comtypes.client
>>> msi = comtypes.client.CreateObject('WindowsInstaller.Installer')
>>> products = msi.ProductsEx['', 's-1-1-0', 7]
Traceback …
Run Code Online (Sandbox Code Playgroud)