Let's start. Create regular dll in VS2005 and create UserControl there. Then expose the interface of the control by creating regular properties, you want to access from outside. (note: I do not like to do it directly updates something, due to security reasons, but for this example it will fine). So you have a public property, but in order to make it visible to COM world, you should create an interface and make your control to inherit from it. This interface will tell COM/COM+ that there are public properties in this AX.
Now we'll have our AX ready and, actually, you can use it already by settings classid attribute of Object in HTML page to something like YouAssemblyName.dll#YourNamespaceInClass.YouControl. You can also generate GUID for it to assure future compatibility. You can set variables and invoke methods of your control by calling TheNameOfObjectInHTML.PropertyOrMEthodExposedByTheInterface . If you want to use GUID as AX identification, just add [Guid("YOUR-GUID-HERE")] attribute above the class definition in code. Well. run it - see nothing? Of cause. You should give your ActiveX Full Trust permissions.
How to do it? Use CasPol.exe utility from SDK. Run CasPol -m -ag 1.2 -hash SHA1 -file MyFile.exe FullTrust. What, actually we have here?
- -m is modifying machine level policy (this set in some cases to user level)
- -ag 1.2 is adding a code group under LocalInternet (in default machine policy)
- -file / -url is membership conditions for new group
- FullTrust is FullTrust :)
Now you can copy (in some cases merge) your config into web or machine application config. If something goes wrong use CasPol -all -reset to restore all defaults.
Still problems? Sign your assembly. use "signtool signwizard" from VS command prompt to invoke certificate sign dialog. If you have code certificate you paid for to one of well known authority, you'll be able to install your AX with yellow strip only in client's machine from internet zone, if your certificate is personal or not trusted in some cases you'll get red bar, in order cases the installation will be terminated.
If you have more then one assembly, you want to deploy, use CAB tools from VS (Setup and Deployment) and don't forget to create INF file for your cab project. Then in HTML Object use codebase attribute to point to your cab. You can also point it to use specific version by using YourAXCAB.cab#Version=a,b,c,d instead of just cab. It's recommended to delay sign your assemblies to be enable easy updates in the future.
That's all, we done. Have a nice day :)