C# classes and JavaScript

M

Mark Rae

Hi,

Can anyone please tell me if it's possible to use classes created in C# with
JavaScript?

E.g. I have created an encryption class in C# and added it to the GAC, so
that it's available to my VS.NET 2003 projects simply by writing

using Encryption.CEncryption;

at the top of my code pages.

I would now like to use this in client-side JavaScript (running on the same
machine) using something like:

<script>

var objEncrpyption = new ActiveXObject("Encryption.CEncryption");

Any assistance gratefully received.

Best,

Mark Rae
 
N

Nick

You might want to check out ComVisibleAttribute and GuidAttribute. That
will expose the class as a COM.
 
N

news.microsoft.com

Hi,

Yes you can do it. Just create ServicedComponent

using System;
using System.Globalization;
using System.EnterpriseServices;
using System.Runtime;
using System.Reflection;

[assembly: ApplicationName("Encryption")]
namespace YogaGeneration
{
public class CEncryption: ServicedComponent
{
.......................................
..........................................
}
}


You can register this componen using
%windir%\Microsoft.NET\Framework\v1.1.4322\RegSvcs.exe.

P.S.
DLL must have strong name (c:\Program Files\Microsoft Visual Studio .NET
2003\SDK\v1.1\Bin\sn.exe)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top