Skip to content

Program crashes when opening Excel #9864

@JohnyL

Description

@JohnyL

I am trying to open Excel 2016 application:

open Microsoft.Office.Interop

[<EntryPoint>]
let main argv =
    let app = new Excel.ApplicationClass(Visible = true)
    0

However, I get the following error:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.

My project contains following COM reference:

<ItemGroup>
    <COMReference Include="Microsoft.Office.Excel.dll">
        <Guid>00020813-0000-0000-c000-000000000046</Guid>
        <VersionMajor>1</VersionMajor>
        <VersionMinor>9</VersionMinor>
        <WrapperTool>tlbimp</WrapperTool>
        <Lcid>0</Lcid>
        <Isolated>false</Isolated>
    </COMReference>
</ItemGroup>

Also tried:

<ItemGroup>
    <COMReference Include="Microsoft.Office.Excel">
        <Guid>00020813-0000-0000-c000-000000000046</Guid>
        <VersionMajor>1</VersionMajor>
        <VersionMinor>9</VersionMinor>
        <WrapperTool>primary</WrapperTool>
        <Lcid>0</Lcid>
        <Isolated>false</Isolated>
        <EmbedInteropTypes>true</EmbedInteropTypes>
    </COMReference>
</ItemGroup>

But this didn't help either. Moreover, when I type app. on the next line, I get the following:

image

It's strange that F# tries to load Excel 2013. It was never installed on my system.

Related information

Provide any related information (optional):

  • Windows 10 x64 Pro 1909
  • .NET 5.0.100-preview.7.20366.6
  • Visual Studio 2019 Preview 16.7.0 Preview 6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions