views:

1802

answers:

3

How do I make an activeX control in a C# library project and then reference it in another ASP.NET wet site project?

+1  A: 

Hi Igor,

If you're using C#/.NET to build your control and consuming it from ASP.NET you would get better performance (and cause yourself much less pain) by referencing it as a standard .NET assembly, bypassing ActiveX altogether. Hope this helps!

Adam

Adam Alexander
The reason I need an activeX control is because I need to access client machines local certificate store.
Igor Zelaya
+1  A: 

Is the ActiveX for the client, or for the server?

If for the server, just use a direct reference to the managed assembly (no need for COM).

Re the client, frankly I'm not sure it is a good idea to be writing ActiveX controls - most browsers won't love them. You'd do better with AJAX and DHTML, or Silverlight / Acrobat / etc for something more complex.

[update] So you want ActiveX at the client... my next though would be "can Silverlight access the certificate store?" I can't find anything, though...

Distributing an ActiveX control (for IE) is usually a matter of packaging the dll into a cab, marking it as safe for scripting and safe for activation. You then place the cab on the web-server, and on the bage you have an <object...>...</object> element specifying the source (code-base) of the cab.

I have to stress that this approach is going to be very hit-and-miss; it won't work on many browsers, and will work soem of the time on IE (depending on the user's security settings). I don't recommend it.

A more practical option might be to write a standalone .NET exe that you package via ClickOnce ("Publish" in VS); drop the ClickOnce deployment on the web-site, and navigate to the application. Voila - full .NET code at the client, without the browser issues.

Marc Gravell
I need to access the clients local certificate store, and Im programming with Microsoft technology. You're right their are other technologies that can acomplish this task like a java applet that is more browser friendly, but because of development constraints I'm stuck with activeX controls
Igor Zelaya
A: 

This article seems to describe what you are asking for.

muratgu
With this solution you need to register the library with regasm tool. Do you know if there is a way of referencing the activeX using the <object> tag?
Igor Zelaya
Using regasm is just one way to do it. You can also provide a codebase (for a .cab file) within the <object> tag to prompt the user to install the control on their computer.
muratgu