.dotx テンプレートを使用し、aspx ページでデータをマージするプログラムを作成しています。このプログラムはローカルの Dev ワークステーションでは完璧に動作しますが、テスト IIS サーバーに展開すると、以下の 2 行目で失敗し、オブジェクト参照エラーが発生します。
以前、Word Com オブジェクトが IIS サーバー上になかったため、問題に遭遇したため、Word をサーバーにロードし、DCom でアクセス許可を設定して、その問題を解決しました。しかし、今では wRange = ..... で始まる行でこのエラーが発生します。
前述したように、プログラムはデバッグ モードでローカルに完全に動作します。
何か案は?
Microsoft.Office.Interop.Word.DocumentClass
System.NullReferenceException: Object reference not set to an instance of an object
コード行:
Document BaseDocument = oWord.Documents.Open(ref oTemplate, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
wRange = BaseDocument.Bookmarks.get_Item(ref endOfDoc).Range;