1

I inherited some code from some coworkers that I have been tasked with updating. I have very little experience with writing code before .NET came to be, so I'm not terribly familiar with things like COM and ActiveX.

Here is what the code sort of looks like:

[Guid("0B84013E-A3D3-1f2f-5E61-4646813BF5DE")]
public interface IGenerator
{
    string GenerateFileName();
}

[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("D499F7A6F-BAC2-4604-BF12-10481C07E924")]
public class Generator : IGenerator
{
    public string GenerateFileName() {
        // implementation details not important
        return "abcdef.xyz";           
    }
}

The project produces a dll file that is registered on the machine using regasm:

regasm Generator.dll /tlb /codebase 

We have a website that is using the code like so:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript" language="javascript">
    function Frob() {
                var as = new ActiveXObject("Test.Generator");
                var fn = as.GenerateFileName();
            }
    </script>
...

<img src="foo.jpg" onclick="Frob()" />

The problem with the code is that: 1) It is not signed 2) They have to register the assembly themselves using regasm

I was tasked with signing the assembly and packaging it up in a CAB file, placing it on the website so that the user is prompted to install it that way.

The tutorials I have seen so far tell you to package it in a CAB and place it in an OBJECT tag on the site:

http://msdn.microsoft.com/en-us/library/aa751974(v=vs.85).aspx

From the website:

Microsoft Internet Explorer 4.0 or later versions handle the OBJECT object and the CODEBASE attribute in the following manner.

  1. Parses the OBJECT object and searches for the CODEBASE attribute. If the CODEBASE attribute is absent or is preceded by a URL-to-object index server in the CodeBaseSearchPath, this index is used to retrieve the file.

  2. Locates the .cab file identified by the CODEBASE attribute.

  3. Expands the files found in the .cab file.

  4. Copies the expanded files to the user's computer (the default directory is \windows\occache).

  5. Registers the objects and/or files that require registration.

  6. Calls the Component Object Model (COM) CoCreateInstance function to create an instance of the specified object.

I have a few problems / questions:

My control doesn't really have a user interface. Does it make sense to still put it in the OBJECT tag?

I tried putting it in the object tag and running the website and it didn't prompt me to install anything. How do I get this to work?

Dismissile
  • 32,564
  • 38
  • 174
  • 263
  • Can you try and explain what you need? I faced some activeX so mybe I can help you – Dor Cohen Feb 11 '12 at 00:45
  • I think the question is not clear, maybe it's good to edit the Title from "ActiveX “Control” and HTML Object Tag" to "Install c# activex cab from “new ActiveXObject”". – Giulio Caccin May 24 '13 at 09:13
  • In that case the question is similar to http://stackoverflow.com/questions/4789110/how-can-i-deploy-a-c-sharp-activex-object-via-a-remotely-loaded-dll-without-pri – Giulio Caccin May 24 '13 at 09:16

0 Answers0