C# 64位侧面加载的应用程序,用于使用代理的Windows运行时组件
我有一个32位(x86)侧面加载的C# 64位侧面加载的应用程序,用于使用代理的Windows运行时组件,c#,windows-runtime,windows-store-apps,ipc,32bit-64bit,C#,Windows Runtime,Windows Store Apps,Ipc,32bit 64bit,我有一个32位(x86)侧面加载的Windows应用商店应用程序,它与代理Windows运行时组件一起工作,工作平稳,可以启动桌面exe,使用反射加载桌面dll,等等 我想让这个侧面加载的应用程序64位。在将应用程序重新构建为x64之后,它再也不能使用代理的Windows运行时组件。错误是 其他信息: 无法将类型为“StoreAppBrokeredWindowsRuntimeComponent.DirectInvoker”的COM对象强制转换为接口类型“StoreAppBrokeredWindo
Windows应用商店应用程序
,它与代理Windows运行时组件一起工作,工作平稳,可以启动桌面exe,使用反射加载桌面dll,等等
我想让这个侧面加载的应用程序64位。在将应用程序重新构建为x64之后,它再也不能使用代理的Windows运行时组件。错误是
其他信息:
无法将类型为“StoreAppBrokeredWindowsRuntimeComponent.DirectInvoker”的COM对象强制转换为接口类型“StoreAppBrokeredWindowsRuntimeComponent.IDirectInvokerClass”。此操作失败,因为对IID为“{50EA3FD3-2383-5445-4002-8CBCBED5DB0F}”的接口的COM组件的QueryInterface调用由于以下错误而失败:类未注册(HRESULT的异常:0x80040154(REGDB_E_CLASSNOTREG))
从医生那里
侧面加载的应用程序可以是64位(前提是同时注册了64位和32位代理),但这是不典型的
问题:
如何构建64位代理
只能生成32位(Win32)代理。如果将WindowsRuntimeProxyStub
更改为x64,它甚至无法编译-存在大量链接错误
因此,32位侧面加载的应用程序、32位代理Windows运行时组件和32位代理是目前为止唯一有效的方法。在Microsoft支持的帮助下,我成功构建了一个64位代理运行时组件,并从一个64位侧面加载的应用程序中使用它 为了便于理解,只需使用以下MS示例项目。您根本不需要修改任何代码文件。但是,模板中有两个错误需要首先修复,请参见本答案末尾的重要注意事项 构建64位代理组件和代理的步骤
SampleProxy
project的平台从Win32改为x64SampleProxy属性
->配置属性
->预处理器
->预处理器定义
,并更改其中两个定义EnterpriseIPCServer
project的平台更改为x64EnterpriseIPCServer
的生成后事件命令行,将x86
或Win32
的每个事件替换为x64
,命令应如下所示:EnterpriseIPCServer
项目SampleProxy
项目call "$(DevEnvDir)..\..\vc\vcvarsall.bat" x64
md "$(TargetDir)"\impl
md "$(TargetDir)"\reference
erase "$(TargetDir)\impl\*.winmd"
erase "$(TargetDir)\impl\*.pdb"
rem erase "$(TargetDir)\reference\*.winmd"
xcopy /y "$(TargetPath)" "$(TargetDir)impl"
xcopy /y "$(TargetDir)*.pdb" "$(TargetDir)impl"
winmdidl /nosystemdeclares /metadata_dir:C:\Windows\System32\Winmetadata "$(TargetPath)"
midl /metadata_dir "%WindowsSdkDir%References\CommonConfiguration\Neutral" /iid "$(SolutionDir)SampleProxy\$(TargetName)_i.c" /env x64 /x64 /h "$(SolutionDir)SampleProxy\$(TargetName).h" /winmd "$(TargetName).winmd" /W1 /char signed /nologo /winrt /dlldata "$(SolutionDir)SampleProxy\dlldata.c" /proxy "$(SolutionDir)SampleProxy\$(TargetName)_p.c" "$(TargetName).idl"
mdmerge -n 1 -i "$(ProjectDir)bin\$(PlatformName)\$(ConfigurationName)" -o "$(TargetDir)reference" -metadata_dir "%WindowsSdkDir%References\CommonConfiguration\Neutral" -partial
rem erase "$(TargetPath)"