我正在尝试使用此代码连接到另一台计算机:
String FullComputerPathName = @"\\mycomputer\";
ConnectionOptions options = new ConnectionOptions();
options.Password = "some_password";
options.Username = "some_user";
ManagementScope scope = new ManagementScope(FullComputerPathName, options);
scope.Connect();
得到例外:
'System.Management.WmiNetUtilsHelper'的类型初始化程序抛出 一个例外。内部异常:ArgumentNullException:值不能 空。
日志跟踪:
“在System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr,Type t)
在System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer [TDelegate](IntPtr ptr)
在System.Management.WmiNetUtilsHelper.LoadDelegate [TDelegate](TDelegate& delegate_f,IntPtr hModule,String procName)
在System.Management.WmiNetUtilsHelper ... cctor()“
我不明白出了什么问题。
谢谢
答案 0 :(得分:0)
我也有同样的问题。 Windows 2012 R2 x 64。
2018-05-31 12:14:51.9866||ERROR|Util.TaskService|System.TypeInitializationException: The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: ptr
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr, Type t)
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer[TDelegate](IntPtr ptr)
at System.Management.WmiNetUtilsHelper.LoadDelegate[TDelegate](TDelegate& delegate_f, IntPtr hModule, String procName)
at System.Management.WmiNetUtilsHelper..cctor()
--- End of inner exception stack trace ---
at System.Management.MTAHelper.IsNoContextMTA()
at System.Management.MTAHelper.CreateInMTA(Type type)
at System.Management.ManagementPath.CreateWbemPath(String path)
答案 1 :(得分:0)
我刚在2008 R2上遇到过同样的问题。
tl; dr :安装.net框架的最新版本(安装4.7对我有用)
更长的版本:
我假设您在.net核心项目中使用Getting distribution for 'stripe==2.32.1'.
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
error: Setup script exited with error in stripe setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
An error occurred when trying to install stripe 2.32.1. Look above this message for any errors that were output by easy_install.
While:
Installing instance.
Getting distribution for 'stripe==2.32.1'.
Error: Couldn't install: stripe 2.32.1
。
反编译Microsoft.Windows.Compatibility
程序集后,我发现它正在寻找.net框架路径,并且正在使用文件System.Management.dll
并正在加载50个方法,但是如果找不到,则它失败。就我而言,它缺少v4.0.30319/wminet_utils.dll
和"GetErrorInfo"
。
我不知道我使用的是哪个.NET Framework版本,但是更新到4.7解决了我的问题。