Skip to content

feat: support 32-bit Office environments (AnyCPU build + ACE provider auto-detection) - #1

Open
KoyaMuramatsu wants to merge 4 commits into
fieldcommissioner:masterfrom
KoyaMuramatsu:feat/x86-32bit-office-support
Open

feat: support 32-bit Office environments (AnyCPU build + ACE provider auto-detection)#1
KoyaMuramatsu wants to merge 4 commits into
fieldcommissioner:masterfrom
KoyaMuramatsu:feat/x86-32bit-office-support

Conversation

@KoyaMuramatsu

Copy link
Copy Markdown

Problem

Users with 32-bit Microsoft Office installed cannot use this server.

Microsoft's policy forbids installing the 64-bit ACE redistributable alongside 32-bit Office — they must match in bitness. Since the server is currently built as x64 and hardcodes Microsoft.ACE.OLEDB.16.0, it fails entirely on machines with 32-bit Office, which is still very common in enterprise environments.

Error observed:

Provider cannot be found. It may not be properly installed.

Solution

Two changes make the server work transparently in both environments:

1. AnyCPU build target

Changed PlatformTarget from x64 to AnyCPU and removed the win-x64 RuntimeIdentifier. This allows the process to run as 32-bit on systems where 32-bit ACE is the only option.

2. OleDB provider auto-detection

Instead of hardcoding Microsoft.ACE.OLEDB.16.0, the server now:

  1. Checks AccessMcp:OleDbProvider in appsettings.json (explicit override)
  2. Probes ACE.OLEDB.16.0 — uses it if available (64-bit systems)
  3. Falls back to ACE.OLEDB.12.0 — used on 32-bit Office systems
  4. Logs a clear warning if neither provider is found

This is implemented in:

  • OleDbService.DetectOleDbProvider() — used by all data operations
  • ComInteropService.ResolveOleDbConnectionString() — used by VBA/COM tools

3. Explicit override via appsettings.json

Users who need to pin a specific provider can set:

{
  "AccessMcp": {
    "OleDbProvider": "Microsoft.ACE.OLEDB.12.0"
  }
}

Files Changed

File Change
MS.Access.MCP.Server.csproj x64AnyCPU, removed RuntimeIdentifier
OleDbService.cs Added DetectOleDbProvider() with 16.0→12.0 fallback
ComInteropService.cs Added ResolveOleDbConnectionString() with same logic
AccessMcpOptions.cs Added OleDbProvider property
appsettings.json Exposed OleDbProvider: null (auto-detect default)

Compatibility

Environment Before After
64-bit Office / ACE 16.0 ✅ Works ✅ Works (same behavior)
32-bit Office / ACE 12.0 ❌ Fails ✅ Works
No ACE installed ❌ Fails ❌ Fails (with clear warning message)

Note: Local build verification was blocked by a corporate proxy. The logic change is minimal and follows standard .NET OleDB provider probing patterns. Happy to adjust if CI surfaces issues.

…vider auto-detection

Users with 32-bit Microsoft Office installed cannot install the 64-bit ACE
redistributable (Microsoft limitation - bitness must match). This change makes
the server work in both 32-bit and 64-bit Office environments.

Changes:
- csproj: PlatformTarget x64 -> AnyCPU, remove win-x64 RuntimeIdentifier
- OleDbService: add DetectOleDbProvider() that probes ACE 16.0 then falls
  back to ACE 12.0 automatically
- ComInteropService: same provider auto-detection via ResolveOleDbConnectionString()
- AccessMcpOptions: add OleDbProvider property for explicit override
- appsettings.json: expose OleDbProvider as null (auto-detect by default)

The explicit override allows users to pin a specific provider in appsettings.json:
  "OleDbProvider": "Microsoft.ACE.OLEDB.12.0"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
村松 幸耶(Koya Muramatsu) added 3 commits March 12, 2026 12:02
AnyCPU on a 64-bit OS defaults to running as a 64-bit process.
32-bit Office only installs the 32-bit ACE OleDB provider, which a
64-bit process cannot load. Prefer32Bit=true ensures the process
runs as 32-bit and can use the existing 32-bit ACE driver.
…bility

Prefer32Bit=true has no effect in .NET 5+ on 64-bit OS.
Only a true 32-bit process can load 32-bit ACE OleDB provider.
win-x86 + SelfContained=true bundles the 32-bit .NET runtime,
so it works regardless of what .NET runtime the user has installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant