Running Client Side C# Using ASP.NET



Hi guys!

I found a great article a while ago about how to write client side C#.
Sadly, I can't find it again now, but here's the jist of what I learnt
to do:

1. Write a C# (or any .NET language) dll.
2. Write a web page in ASP.NET.
3. Put the dll from 1 into the virtual directory that 2 lives in (the
root).
4. Use an object tag in the web page to download the dll onto the
client machine when the page loads.
5. Fire some javascript from within the web page to access methods in
the dll client side, effectively running code from 1 on the client,
with no need for post backs etc...

This sounds too good to be true, right? It really does work! There is
an obvious draw back: The client needs to have the .NET framework
installed! This is obviously a problem if you want to expose your
functionality across the whole of the web, but for a controlled area,
such as a company network, this method can be a great way to deploy
enhanced web applications. There's no installation needed (apart from
the framework), and if the dll mentioned in 1 is updated, the web page
automatically downloads the new version of the component. I have put
this technology to great use within my company: I have written a web
page that provides spell checking on text fields. Clearly, I don't want
to send the page back to the server every time I want to check the
spelling, so I have written a .NET dll that launches a contained form.
Text from a HTML text box is passed to the form, which checks the
spelling against a dictionary file embedded in my .NET dll. When the
form (which is displayed as modal from IE) closes, the corrected text
is put back into the HTML text box. Everything works dynamically.

Here are some technical details:

The object tag mentioned in 4 looks like this:

<OBJECT id="textEditor"
classid="http:ClientSideCode.dll#ClientSideCode.TextEditor" name="Text"
VIEWASTEXT></OBJECT>

Note that the classid is made up as follows: "http:{DLL File
Name}#{Default DLL namespace}.{Class name}

The javascript function would then look like this:

function EditText()
{
alert(textEditor.EditText(document.Form1.txtText.value);
}

....assuming a control called txtText exists. Of course, the result from
this call need not be put into a message. You can do anything with the
return value, and pass a string from any source.

The method that got called in the C# dll would look something like
this:

public string EditText(string Text)
{
//Implementation
return Text;
}

However, and here is the but.... I've had this method working fine on a
whole host of machines, but every now and then I find a machine that
simply refuses to allow this method to work, even though the EXACT SAME
code works fine on other machines.

This is the message I get:

Error: Object doesn't support this property or method

I figure there must be a setting I need to tweak on these machines to
make it work, but I have no idea what I'm looking for. Can anyone
help!? I'm all out of ideas!

Thanks in advance for your help!

Steve.

.



Relevant Pages

  • Re: RegAsm.exe missing from client machines
    ... I think that is in the Client Framework directory, or may be only in the ... > I've developed a VB6 application that uses a VB.Net dll. ... > distributed to client machines it works fine except for a few cases. ... and the .Net dll is not being registered correctly (no tlb ...
    (microsoft.public.dotnet.languages.vb)
  • Re: VPN tunnel with XP Home on remote end cant connect to server in App Mode
    ... MSLicensing registry key, rebooted, installed VPN client (Watchguard) ... Administrator seemed to get the license properly. ... I did not config these machines prior to this so there could have been ... Pro and obviously have a valid license. ...
    (microsoft.public.win2000.termserv.clients)
  • Re: A case for windows firewall
    ... Renewing SAV for definitions on 50 machines is significantly cheaper than buying a newer version and 50 licenses. ... I'm not saying a client should stick with SAV v4. ... I use the Windows firewall, but I cannot help but ask, "Where was the antivirus software that should have stopped the virus?" ...
    (microsoft.public.windows.server.sbs)
  • Re: 1058 and 1030 errors revisited
    ... Are you sure about the symptoms ie when the11th or 12th user logs ... Does the issue occour only on some machines? ... We have four servers to ... There are about sixty client ...
    (microsoft.public.windows.group_policy)
  • Re: VB6 Winsock action on Server
    ... separate dll instance for each client request process it, ... of your 'dll' (assuming it is an ActiveX-Dll? ...
    (microsoft.public.vb.general.discussion)