title: Running C# Interop Control ActiveX on Client Side from ASP.NET
body: <p>I am trying to make a simple web application using ASP.NET and Interop COM.</p>
  
  <p>The main question is: How to make Interop COM works in client side?</p>
  
  <p>I am Using:<br> 
  IIS Windows Server 2008<br>
  C# Interop COM - Visual Studio 2010<br>
  Asp .NET - Visual Studio 2010</p>
  
  <p>After looking at these articles<br> <a href="http://msdn.microsoft.com/en-us/library/aa479302.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa479302.aspx</a><br> and <a href="http://msdn.microsoft.com/en-us/magazine/cc301832.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc301832.aspx</a>.<br> I tried to use the component on the client side in two ways:</p>
  
  <p>First:</p>
  
  <pre><code>&lt;object id="Obj" codebase="MyApp.dll#version=1,0,0,0" classid="clsid:C6659361-1625-4746-931C-36014B146679" VIEWASTEXT&gt;&lt;/object&gt; 
      &lt;script type="text/javascript" &gt;
          function test() {
              alert('TEst');
              Obj.PrintHi();
              alert('and');
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>Second:
  in .aspx</p>
  
  <pre><code>&lt;object id="Obj" codebase="MyApp.dll#version=1,0,0,0" classid="clsid:C6659361-1625-4746-931C-36014B146679" VIEWASTEXT&gt;&lt;/object&gt;
  </code></pre>
  
  <p>and in .cs file:</p>
  
  <pre><code>RegisterClientScriptBlock("showSaveMessage", "&lt;script language=\"JavaScript\"&gt; Obj.PrintHi();  &lt;/script&gt;");
  </code></pre>
  
  <p>In server side I open Internet Explorer and works like a charm. But in client side appears: Object doesn't support this property or method.</p>
  
  <p>I also tried:</p>
  
  <pre><code>&lt;%
      set Obj = CreateObject("MyApp.MyClass")
  
      Obj.PrintHi
  %&gt;
  </code></pre>
  
  <p>Works for both side, but only call MyApp.dll installed on the server side.</p>
  
  <p>Using 'object tag' is the correct way? Is there another way to use COM in client side? How to configure IIS to avoid Object doesn't support this property or method in client side?</p>
  
  <p>Thanks in Advance</p>
  
  <p><strong>1# Update</strong></p>
  
  <p>I create ASP.NET C# in Visual Studio 2010 on Windows XP 32bits that uses a C# Interop COM.
  On my machine "Windows XP" I do Start Debugging and IE page opens with my application. This works.<br>So I copied the project to Windows Server 2008 and added the project in IIS. When I run IIS opens IE and this works.<br><br>After this I tried to make the final test, So I open the IE on Windows XP and type the address that Windows Server generated, fine, I can see the page, but when I click to run the function, Appears: "Object does not support this property or method".</p>
  
  <p>Server:<br>
  Windows 2008 R2 64bits<br>
  IE version 9</p>
  
  <p>Client:<br>
  Windows XP 32bits<br>
  IE version 8</p>
  
  <p><strong>2# Update</strong></p>
  
  <p>I tried another test</p>
  
  <p>I made a new Component COM<br>
  IClassTest.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Runtime.InteropServices;
  
  namespace MyCOM
  {
      [ComVisible(true)]
      [Guid("8F388924-7743-4166-993F-CBF897D08A8B")]
      public interface IClassTest
      {
          string getString(string str);
      }
  }
  </code></pre>
  
  <p>ClassTest.cs</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Runtime.InteropServices;
  
  namespace MyCOM
  {
      [ComVisible(true)]
      [Guid("1AE4AD64-A951-4E6C-8600-AA1F08810DDD")]
      public class ClassTest : IClassTest
      {
          public string getString(string str)
          {
              return str + "1";
          }
      }
  }
  </code></pre>
  
  <p>In AssemblyInf.cs has <code>[assembly: ComVisible(true)]</code></p>
  
  <p>I made another asp application:</p>
  
  <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeBehind="Default.aspx.cs" Inherits="asp_test._Default" %&gt;
  
  &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
  &lt;object id="Obj" codebase="MyCOM.dll#version=1,0,0,0" classid="clsid:1AE4AD64-A951-4E6C-8600-AA1F08810DDD" VIEWASTEXT&gt;&lt;/object&gt; 
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
  
  &lt;script type="text/javascript" &gt;
      function test() {
          var test = Obj.getString('2');
          alert(test);
      }
      &lt;/script&gt;
      &lt;input name="btnTest" value="Call COM" onclick="test()" style=" width: 400px;" type="button"&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I change IE settings to display ActiveX not trust and run the program.
  In windows XP works, In Windows Server works. But when try to call the page from windows XP "Windows XP call Windows 2008 page" appears: "Object doesn't support this property or method"</p>
  
  <p>If on client side I do <code>regasm /u MyCOM.dll</code> the IE prompted to install the component.
  The dll is stored in the <code>C:\WINDOWS\Downloaded Program Files</code>, if I try to install more than once, creates a folder called <code>CONFLICT.1</code>.. <code>C:\WINDOWS\Downloaded Program Files\CONFLICT.1</code> very strange. I also tried to register this downloaded component with <code>regasm MyCOM.dll /codebase</code>.</p>
  
  <p>Server .NET: <code>C:\Windows\Microsoft.NET\Framework\v4.0.30319</code><br>
  Client .NET: <code>C:\Windows\Microsoft.NET\Framework\v4.0.30319</code></p>
  
  <p>Why not work? It makes no sense.</p>
  
  <p><strong>3# Update</strong></p>
  
  <p>I ran on another machine "Client". I change IE settings to run not safe ActiveX. And Works, After this I tried on Windows XP Client I reseted the settings and set up again to run ActiveX not safe. This Works.<br><br>
  Now the problem is related to Install Interop COM from ASP. I tried to install but appears: Object doesn't support this property or method. I think it is related to <code>Safe Inicialization</code>. I found this link: <a href="http://msdn.microsoft.com/en-us/library/aa751977.aspx#iobjsafe" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa751977.aspx#iobjsafe</a> but is for C++, Is there C# examples?</p>
  
  <p><strong>4# Update</strong></p>
  
  <p>I tried to use:<br>
  <code>public class ClassTest : System.Windows.Forms.UserControl, IClassTest</code><br>
  I also tried to do a .cab file but does not work.</p>
  
  <p>Have I to make wpf project? Why this does not work?</p>