概念実証 Web アプリケーションを開発しています。ユーザーの PC にインストールされている Word アプリケーションを開くボタンを備えた Web ページです。
Visual Studio 2008 Express (Windows XP クライアント、LAMP サーバー) の C# プロジェクトに行き詰まっています。私は.NET チュートリアルで ActiveX コントロールを作成するに従って、いくつかの調整を行った後、正常に動作しました。次に、Word を開くためのボタンを追加しました。
問題は、プロジェクトから Microsoft.Office.Interop.Word を参照できることですが、Web ページからはアクセスできません。エラーには、「そのアセンブリは部分的に信頼された呼び出し元を許可していません」と表示されます。
私は .NET のセキュリティについて多くのことを読んできましたが、今では完全に道に迷っています。免責事項: 私は 4 日前から .NET に夢中です。
この問題を回避しようとしましたが、光が見えません!! それが可能になるかどうかさえわかりません!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Security.Permissions;
using System.Security;
[assembly: AllowPartiallyTrustedCallers]
namespace OfficeAutomation
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void openWord_Click(object sender, EventArgs e)
{
try
{
Word.Application Word_App = null;
Word_App = new Word.Application();
Word_App.Visible = true;
}
catch (Exception exc)
{
MessageBox.Show("Can't open Word application (" + exc.ToString() + ")");
}
}
}
}