【问题标题】:IntPtr.Size is always 4 despite AnyCPU in 64 bit OS尽管在 64 位操作系统中使用 AnyCPU,但 IntPtr.Size 始终为 4
【发布时间】:2017-05-26 17:20:36
【问题描述】:

我正在构建一个在 64 位操作系统和 64 位 Outlook 上运行的 Outlook 插件。 但是,我无法获得正确的指针大小以触发 RedemptionLoader 代码加载 64 位 dll ......它总是给我指针大小是 4。

我已经阅读了以下内容并遵循了他们的建议,但是不行......

why IntPtr.size is 4 on Windows x64?

IntPtr in 32 Bit OS, UInt64 in 64 bit OS

所以在我的项目中,Visual Studio 2015 中的 C# 项目中,我将其设置为 Any CPU,然后在我的 64 位 WiX 安装项目中,我确保它具有 x64 作为 @987654327 @。像这样,

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">

当我尝试加载我的加载项并转储指针大小 "Pointer size? " + IntPtr.Size 时,它只打印 4 而不是我期望的 8...

我还缺少什么...?

Windows 10 64 位

Office 365,Outlook 64 位

编辑:看我不傻,操作系统和 Outlook 都是 64 位的。阅读其他帖子并尝试后在这里发帖真的是我最后的手段......

即使在安装插件的过程中,Add-in Express 也会检测到并安装为 64 位版本,而不会抛出任何错误...

Add-in Express Registrator Log File: 01/11/2017 15:36:47

Installation directory: C:\WINDOWS\Installer\
Registrator version: 8.4.4395.0
Operating System: Microsoft Windows 10 Professional (build 14393), 64-bit
Process Owner: System
Command Line: "C:\WINDOWS\Installer\MSI5FB0.tmp" /install="C:\Program Files\Blah\Blah.dll" /log=%RoamingAppDataFolder%/Blah
Run 'As Administrator': Yes
Process Elevated: Yes
Integrity Level: System
UAC (User Account Control): On
--------------------------------------------------------------
15:36:47 0448 Starting the add-in registration process.
15:36:47 0448 Loading mscoree.dll
15:36:47 0448 Success.
15:36:47 0448 .NET Framework installation directory: 
15:36:47 0448 The latest version of .NET Framework: 'v4.0.30319'
15:36:47 0448 Loading CLR: v4.0.30319.
15:36:47 0448 Calling CLRCreateInstance method.
15:36:47 0448 Success.
15:36:47 0448 Calling GetRuntime method.
15:36:47 0448 Success.
15:36:47 0448 Checking if the hosting API of .NET Framework v4.0 beta is installed.
15:36:47 0448 The hosting API is up to date.
15:36:47 0448 Calling GetInterface method for the CorRuntimeHost interface.
15:36:47 0448 Success.
15:36:47 0448 Starting CLR...
15:36:47 0448 Success.
15:36:47 0448 Getting the CLR version.
15:36:47 0448 The CLR v4.0.30319 has been initialized successfully.
15:36:47 0448 Creating a new domain setup.
15:36:47 0448 Success.
15:36:47 0448 The 'shadow copy' is disabled.
15:36:47 0448 Creating a new application domain.
15:36:47 0448 Success.
15:36:47 0448 Getting the base directory for the domain.
15:36:47 0448 Success. The directory is 'C:\Program Files\Blah\'.
15:36:47 0448 Searching for the Add-in Express core library.
15:36:47 0448 Success. The 'AddinExpress.MSO.2005.dll' file is found.
15:36:47 0448 Creating an instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
15:36:47 0448 Assembly identity is 'AddinExpress.MSO.2005'.
15:36:47 0448 Success.
15:36:47 0448 Unwrapping the instance of the 'AddinExpress.Deployment.ADXRegistrator' class.
15:36:47 0448 Success.
15:36:47 0448 Calling the managed registration procedure (DISPID = 1610743823).
15:36:48 0448 Registration success.
15:36:48 0448 The add-in registration process is completed with HRESULT = 0.

【问题讨论】:

  • 你确定主进程是64位的吗?

标签: c# outlook 64-bit outlook-redemption


【解决方案1】:

如果是4,可以确定进程是32位的。编译为“任何 CPU”将匹配主机应用程序 (Outlook) 的位数,而不是主机操作系统。

Outlook 真的说它是 64 位的吗?

【讨论】:

  • 是的...它说的是 64 位,我真的不知道为什么它会打印 4。我构建插件的机器安装了 32 位 Outlook,但我不这么认为在目标机器上会很重要吗?
  • 调试时是否使用VSTO托管进程?
  • 我确实在属性“调试”>“启用调试器”>“启用 Visual Studio 托管进程”中看到了该选项,并且该框已选中。是你说的那个吗?我已取消选中该框并重建了解决方案,仍然一样......
  • 如果您明确定位 x64 会发生什么?
  • 我已经完全创建了一个全新的安装程序项目,并重建并重新打包了整个东西,安装了它,一切运行良好,您的 Redemption 甚至加载了正确的 64 位 dll,只有在卸载过程中它尝试加载 32 位(由于指针大小为 4)这完全是头脑=吹...
猜你喜欢
  • 2010-11-07
  • 1970-01-01
  • 2015-03-08
  • 1970-01-01
  • 2012-06-12
  • 2013-08-29
  • 2011-02-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多