【发布时间】:2013-12-14 19:44:42
【问题描述】:
尝试使用位于 System 程序集中的 System.Security.Cryptography.X509Certificates 的 Microsoft .NET 类会引发以下错误:
$certificate2 = new DOTNET('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Security.Cryptography.X509Certificates.X509Certificate2');
com_exception: 无法实例化 .Net 对象 [Unwrapped, QI for IDispatch] [0x80004002] 不支持此类接口 在 ...\test.php 第 2 行
而以下调用确实有效并返回 DOTCOM 实例。
$certificate = new DOTNET('mscorlib', 'System.Security.Cryptography.X509Certificates.X509Certificate');
$form = new DOTNET('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', 'System.Windows.Forms.Form');
System.dll 或其包含在 System.Security.Cryptography.X509Certificates 中的类有什么特别之处吗?
为什么这个文件或类不能使用?
深入挖掘
异常源于php_dotnet extension source code 第 250 行中的一个失败的方法调用。但这对我来说太低级了。电话是:
hr = IUnknown_QueryInterface(V_UNKNOWN(&unwrapped), &IID_IDispatch, &V_DISPATCH(&obj->v));
旁注
- PHP 版本为 5.5.5
- 这发生在 Windows 7 和 Windows Server 2008 R2 机器上
- 程序集似乎可以正确访问,但找不到类
- 选择的 .NET Framework 版本为 2.0.0.0 (= 4
- mscorlib 中的密码学类不够用,因为功能有限
【问题讨论】:
标签: php .net assemblies