-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do ComWrappers support proxies well? #101909
Comments
Trying your example, it fails at this line: doDownload.SetProperty(DODownloadProperty.DODownloadProperty_LocalPath, &filePathVarient); The return HRESULT is 0x80010123 (CO_E_FAILEDTOIMPERSONATE). |
Thank you for your check, I noticed this problem. When I tested it on my side, it only appeared in ComWrappers, build-in COM didn't happen 所以我很想知道,我的代码是写的发生了bug,还是 ComWrappers 对 proxy 的支持有问题? |
Though I'm not familiar with ComWrappers, there are multiple interop-related issues or suggestions in your code:
I'm not sure what can be "proxy" releated here. The |
For your 1,3 suggestions, you can try to modify the code I provided, you can check if it supports com source generation |
They are not supported at all. Trying to use them on com interface causes error.
It's before reaching any method. |
So that's the real reason for it, and it requires us to make some adjustments to the code. Line 189 in 5e949e1
|
I'm referring to this code in your project: IntPtr callbackPointer = comWrappers.GetOrCreateComInterfaceForObject(new UnknownWrapper(doDownloadStatusCallback).WrappedObject, CreateComInterfaceFlags.None); You aren't passing the |
It seems that the authentication information did not being set correctly on the proxy object by Related to #101157, cc: @AaronRobinsonMSFT does it ring any bells? As a workaround, you can try calling CoInitializeSecurity(0, -1, 0, 0, 0, 3, 0, 0x20, 0);
[LibraryImport(Ole32), PreserveSig]
static partial int CoInitializeSecurity(nint pSecDesc, nint cAuthSvc, nint asAuthSvc, nint pReserved1, int dwAuthnLevel, int dwImpLevel, nint pAuthList, int dwCapabilities, nint pReserved3); |
Description
Do ComWrappers support proxies well?
ComWrappers 是否能很好的支持代理?
I tried using ComWrappers and the built-in COM support to call the deliveryoptimization.h API (deliveryoptimization) separately to try to download the file. But when using the built-in COM support, the file downloads normally, and when using ComWrappers, the download fails, returning an unknown HRESULT error code. So how do we solve this problem?
我尝试使用 ComWrappers 和内置的COM支持分别调用 deliveryoptimization.h 的 API(传递优化)尝试下载文件。但是当使用内置的COM支持时,文件可以正常下载,使用 ComWrappers 时,下载失败,返回了一个不知道是什么的HRESULT 错误代码。所以请求一下这个问题该怎么解决?
Reproduction Steps
1.创建两种API调用模板,一种是内置的COM支持下,另一种是基于ComWrappers的。
2.使用 CoCreateInstance 创建 IDoManager 的接口实例对象
3.调用 IDoManager 接口的 CreateDownload 方法创建 IDODownload 接口实例对象,创建新的下载任务。
4.获取 IDoDownload 接口对象的指针,并使用 CoSetProxyBlanket 为该接口创建代理
5.为 IDoDownload 接口对象添加下载信息
6.调用 IDoDownload 接口的 Start() 方法启动下载
Expected behavior
基于 ComWrappers 调用 Start 方法返回的结果为 0,表示成功创建下载
A call to the Start method based on ComWrappers returns 0, indicating that the download was successfully created
Actual behavior
基于内置支持的接口返回的HRESULT 错误代码为 0,表示下载任务成功启动。基于 ComWrappers 的返回的 HRESULT 错误代码为 0x80D02018,不知道对应的是什么错误信息
If HRESULT error code 0 is returned based on the built-in supported interface, the download task is successfully started. The HRESULT error code returned by ComWrappers is 0x80D02018. What is the corresponding error message
Regression?
None
Known Workarounds
If you want to successfully create the download task, you must convert to built-in COM support, but this does not work well with Native AOT
如果想成功创建下载任务,必须转换为内置的 COM 支持,但是这样就不能很好的兼容 Native AOT
Configuration
.NET Version: .NET 9 preview3
OS version: Windows 11 22635.3570
Architecture:X64
Other information
Screenshot of code error based on ComWrappers launch download task
基于 ComWrappers 启动下载任务错误的代码截图
Screenshot of code for successfully starting download tasks based on built-in COM support
基于内置的COM支持成功启动下载任务的代码截图
Test source code
测试源代码
DeliveryOptimizationTest.zip
The text was updated successfully, but these errors were encountered: