title: Open the Word Application from a button on a web page
body: <p>I'm developing a proof of concept web application: A web page with a button that opens the Word Application installed on the user's PC.</p>
  
  <p>I'm stuck with a C# project in Visual Studio 2008 Express (Windows XP client, LAMP server). I've followed the <a href="http://www.c-sharpcorner.com/uploadfile/dsandor/activexinnet11102005040748am/activexinnet.aspx" rel="nofollow noreferrer" title="Writing an ActiveX Control in .NET">Writing an ActiveX Control in .NET</a> tutorial and after some tuning it worked fine. Then I added my button for opening Word.</p>
  
  <p>The problem is that I can reference the Microsoft.Office.Interop.Word from the project, but I'm not able to access it from the web page. The error says "That assembly does not allow partially trusted callers".</p>
  
  <p>I've read a lot about security in .NET, but I'm totally lost now. Disclaimer: I'm into .NET since 4 days ago.</p>
  
  <p>I've tried to work around this issue but I cannot see the light!! 
  I don't even know if it will <strong>ever</strong> be possible!</p>
  
  <pre><code>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() + ")");
              }
          }
      }
  }
  </code></pre>