问题描述
我觉得我在这里丢失了一些东西,并且周围似乎没有太多的文档.基于此( http://msdn.microsoft.com/en-us/library/vstudio/aa702681(v = vs.100).aspx ) 我应该能够访问MessageLogging的< system.ServiceModel><诊断>< messageLogging>使用WMI在运行时添加元素.
I feel like I'm missing something here and there doesn't appear to be much documentation around it. Based on this (http://msdn.microsoft.com/en-us/library/vstudio/aa702681(v=vs.100).aspx) I should be able to access the MessageLogging's <system.ServiceModel><diagnostics><messageLogging> element at runtime using WMI.
我知道System.Management命名空间已被标记为不赞成使用新(MI)功能,但这是针对4.0应用程序的,因此MI不适用,但是对于我来说,我一生都没有AppDomainInfo管理路径的任何ManagementObjects. 对于我来说,WMI用于托管在IIS中的WCF服务是一件很奇怪的事情,IIS是一种按请求类型的项(即,它不像一直在后台运行的SQL Service一样).此功能只能用于WCF吗? 托管在WAS中?我想念一些愚蠢的简单东西吗?
I know that the System.Management namespace has been marked for deprecation for the new (MI) functionality, but this is for a 4.0 app so MI doesn't apply, but for the life of me I'm not getting the any ManagementObjects for the AppDomainInfo management path. It seams rather odd to me that WMI would be used for a WCF service that is hosted in IIS which is an upon request type item (i.e. It's not like a SQL Service that's always running in the background). Could this functionality only be intended for WCF hosted in WAS? Am I missing something stupid simple?
我也尝试了ObjectQuery/ManagementObjectSearcher,但不走运.我能够使用Connect()调用没有任何问题,但是由于某种原因,我没有得到任何结果.有什么建议吗?
I've tried ObjectQuery/ManagementObjectSearcher as well, no luck. I'm able to user the Connect() calls without any problems, but for some reason I don't get any results back. Any suggestions?
ConnectionOptions connOptions = new ConnectionOptions ();
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Authentication = AuthenticationLevel .PacketPrivacy;
connOptions.Authentication = AuthenticationLevel.PacketPrivacy;
ObjectGetOptions getOptions = new ObjectGetOptions ();
ObjectGetOptions getOptions = new ObjectGetOptions();
getOptions.Timeout = 新 系统. TimeSpan (0, 0, 30);
getOptions.Timeout = new System.TimeSpan(0, 0, 30);
ManagementScope scope = 新 ManagementScope ( @""\\.\ root \ ServiceModel" , connOptions);
ManagementScope scope = new ManagementScope(@"\\.\root\ServiceModel", connOptions);
ManagementPath path = 新 ManagementPath ("appdomaininfo" );
ManagementPath path = new ManagementPath("appdomaininfo");
ManagementClass serverClass = new ManagementClass (作用域,路径,getOptions);
ManagementClass serverClass = new ManagementClass(scope, path, getOptions);
serverClass.Get();
serverClass.Get();
instances = serverClass.GetInstances();
instances = serverClass.GetInstances();
推荐答案
首先,请确保已使用以下配置文件:
First please try to make sure that you have used the following config file:
<diagnostics wmiProviderEnabled="true" performanceCounters="All">
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
然后,请尝试查看以下文章:
Then please also try to check the following articles:
#使用Windows Management Instrumentation进行诊断:
http://msdn.microsoft.com/en-us/library/ms735120.aspx .
#Using Windows Management Instrumentation for Diagnostics:
http://msdn.microsoft.com/en-us/library/ms735120.aspx .
#WMI提供程序:
http://msdn.microsoft.com/en-us/library/ms751442.aspx .
#WMI Provider:
http://msdn.microsoft.com/en-us/library/ms751442.aspx .
最好的问候,
彭爱美
Best Regards,
Amy Peng
这篇关于通过WMI WCF AppDomainInfo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!