0

C# で Word 2007 用のアドインを作成しました。アドインを配布するために、ClickOnce インストーラーを使用しました。ただし、このアドインは Word 2010 では機能しません。vsto.log ファイルに次のエラーが生成されます。

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
   at Microsoft.VisualStudio.Tools.Office.Word.Internal.IWordHostItemProviderProxy..ctor(IHostItemProviderExtendedContract hostItemProvider)
   at Microsoft.VisualStudio.Tools.Office.Word.Internal.IWordHostItemProviderProxy.GetProxy(IHostItemProviderExtendedContract contract)
   at Microsoft.VisualStudio.Tools.Office.Word.Internal.LocalWordServiceProvider.GetService(Type serviceType)
   at Microsoft.VisualStudio.Tools.Applications.Internal.LocalServiceProvider.System.IServiceProvider.GetService(Type serviceType)
   at Microsoft.VisualStudio.Tools.Office.EntryPointComponentBase.Microsoft.VisualStudio.Tools.Applications.Runtime.IEntryPoint.Initialize(IServiceProvider hostContext)
   at Microsoft.VisualStudio.Tools.Applications.AddInAdapter.ExecutePhase(ExecutionPhases executionPhases)
   at Microsoft.VisualStudio.Tools.Office.Internal.OfficeAddInAdapterBase.InitializeEntryPointsHelper()

アドインが検索する Microsoft.Office.Interop.Word dll と、Word 2010 のシステムで使用可能なものとの間にバージョンの不一致があることは理解していますが、この問題を修正する方法がわかりません。Googleで検索しましたが、興味深いものは何もありませんでした。助けてください。

4

3 に答える 3

1

最後に問題を追跡することができました。すぐに投稿できなくてすみません。この問題の原因となった PIA ライブラリではなく、間違ったライブラリにリンクしていたようです。変更を行った後、問題は修正されました。

于 2011-08-01T13:29:03.003 に答える
0

まず、以下のコードを使用して PIA (primary Interop Assembly) がシステムにインストールされていることを確認します

   bool IsPrimaryInteropAssembliesInstalled()
    {
        try
        {
            if (Assembly.Load("Policy.11.0.Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") != null)
            {
                return true;
            }
        }
        catch (Exception)
        {
        }
        return false;
    }

次に、Office PIA をhttp://www.microsoft.com/download/en/details.aspx?id=18346からダウンロードします。以下のコードを実行します

void InstallPrimaryInteropAssemblies()
    {
        try
        {
            string str = "path\o2007pia.msi";
            System.Diagnostics.Process process = new System.Diagnostics.Process
            {
                StartInfo = { FileName = str }
            };
            process.Start();
            while (!process.HasExited)
            {
                System.Threading.Thread.Sleep(0x3e8);
            }
        }
        catch (Exception exception)
        {

        }
    }
于 2011-07-25T10:23:34.273 に答える
0

クリック ワンス インストール プロジェクトで、これらのワード アセンブリの特定のバージョン チェックをオフにする必要があると思います。

于 2011-03-28T16:16:54.870 に答える