1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

.NET (Core系)から、Office PIA ライブラリを参照するには

Posted at

忘備録として

.NET(Core系)から、Office PIA を参照する場合は以下のフォルダにあるモジュールを参照します。

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Visual Studio Tools for Office\PIA

単純に参照しただけだと相対パスになっているので(........ となっている)、プロジェクトファイル(.csproj/.vbprojなど)を直接開き、Reference IncludeHintPath$(MSBuildProgramFiles32)\Microsoft Visual Studio\...と書き換えます。

PIA なので、埋め込みにしたいという場合は<EmbedInteropTypes>True</EmbedInteropTypes>を追加しておきます(こちらはプロパティから操作可能)。

後の使い方は .NET Framework と同じ。Marshal.RelaseComObject()を忘れると、ゾンビアプリが出来上がるので注意しましょう(デバッグ実行して強制終了した場合も同様に生き残るので要注意)。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?