Deployment of Windows User Controls for Web Pages

  • Thread starter Thread starter Wayne Gibson
  • Start date Start date
W

Wayne Gibson

Hi,
Was wondering if anybody could point me in the right direction.

I'm looking at developing a Windows User Control using Visual Studio .NET
2005 in C#. The user control is to be used on a web page to replace an
existing Java applet. One of the main reasons for switching from Java to
the Windows User Control is to reduce the amount of the time spent maintain
two lots of source code, keeping the online and offline versions in sync.
So the creating a Windows User Control, would help in this matter.

I haven't seen many samples on how to achieve creating a Windows User
Control using C#. The ones that I have seen, seem to implement the Windows
User Controls like ActiveXs. Using the Object Tag in the HTML file, as
follows:

<object id="HelloWorldControl1"
classid="http://localhost/HelloWorldControlHost/HelloWorldControl.dll#HelloWorldControl.HelloWorldCtl"
height="500" width="500" VIEWASTEXT>
</object>

Using the # to specify the Assemblyname and class to invoke.

Firstly, is this the correct way of doing it. Or is there a better method
that I haven't found as yet?

I also noticed that the when the custom control is download, it states that
it is unsigned. Am I correct in thinking that I will need to sign the
custom control, using a digital signature from Verisign?
Once signed, will the user still be prompted to install the control or is
there someway of avoiding the dialog be presented to them?

Is it also possible to use a cab file, just in case there are an additional
dlls that are required by the custom control ? If so will this be
transparent to the users, or will they see some sort of installation being
performed?

My major problem, is that I want this to work on as many machines as
possible. But nowadays a lot of system managers are restricting what can
and can't be installed on the users machines and I don't want to lose these
users....

Thanks

Wayne
 
Hi,

In fact, you will develop a class library application (dll) with a class,
inherited from UserControl class. That class will be your ActiveX like
UserControl. Then you may use that class within any scrpting language and/or
on a web site. The main problem is ActiveX technology bases upon COM not
CLR.

The first thing is that the clients that will host your control should have
the proper version of .NET Framework installed on their system.
And be careful, .NET assemblies are not automatically registered on the OS,
unless you tell them to register themselves to the OS.
So in order to register the assemblies on the clients you must sign them
with a public key which can be produced by using the "sn.exe" tool available
in the .NET Framework SDK bundle. But this is not the signature that
authenticates the developer, I mean this is not the certificate of
authority. And after signing the assembly you may register it (e.g
regasm.exe from SDK)

also if you have a authenticode signature you may sign the assembly using
the makecab.exe...

For more resources take a look at the subjects "registering a .NET
assembly", "COM+ vs. .NET"...

Step By Step:

1. Build the dll
2. Sign with strong name (sn.exe)
3. Makecab and AuthentiCode
4. Register the assembly
 
Correct...I'd avoid the use of windows user controls in
a web browser like the plague. Even for IE users, you'll
run into all sorts of users who are either not permitted to
install your control or have problems getting it to work
once installed because of security settings.

It isn't worth the headaches...

Unless you need to work with files on the user's
desktop, I'd suggest writing the functionality in
script or write the core functionality you need
in the flash player. Many companies will permit
flash installs if it isn't already installed (which it is
very, very likely to already be there).
 
Wayne,

Please do not cross post.
I haven't seen many samples on how to achieve creating a Windows User
Control using C#. The ones that I have seen, seem to implement the Windows
User Controls like ActiveXs. Using the Object Tag in the HTML file, as
follows:

[object id="HelloWorldControl1"
classid="http://localhost/HelloWorldControlHost/HelloWorldControl.dll#HelloWorldControl.HelloWorldCtl"
height="500" width="500" VIEWASTEXT]
[/object]

Using the # to specify the Assemblyname and class to invoke.

Firstly, is this the correct way of doing it. Or is there a better method
that I haven't found as yet?

This is the new way of doing it. When using the new syntax, the security
will be managed by the CLR's CAS (code access security system).
Your control won't be able to do much w/out user's approval.
I also noticed that the when the custom control is download, it states that
it is unsigned. Am I correct in thinking that I will need to sign the
custom control, using a digital signature from Verisign?
Yes.

Once signed, will the user still be prompted to install the control or is
there someway of avoiding the dialog be presented to them?

It probably depends on user's Internet Explorer settings.
Is it also possible to use a cab file, just in case there are an additional
dlls that are required by the custom control ? If so will this be
transparent to the users, or will they see some sort of installation being
performed?

It is, but in this case you cannot use the way described above.
You have to do it the old ActiveX way:

- register the Control for COM interop
- mark the control: [ComVisible(true)]
- give it a GUID: [Guid("....")]
- package the cab
- sign the cab
- deploy

CRL's CAS doesn't interact (by default) with .NET controls exposed
as ActiveX objects. However, restrictive admins are able to ban
every .NET component they don't explicitly trust.
My major problem, is that I want this to work on as many machines as
possible. But nowadays a lot of system managers are restricting what can
and can't be installed on the users machines and I don't want to lose these
users....

Using .NET Controls would "slightly" limit the audience:
Internet Explorer and the .NET runtime are required.

Rob
 
Back
Top