473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using a c# assembly client side

Hi

I want to use one of my c# assemblies on the client browser (IE), say using
javascript to call it.

I have seen loads of people asking how they can host a WinForms control in
IE but all I want to do is call a few methods in my assembly which do not
have or need a UI.

The <object> tag seems to play a big role here but I haven't managed to get
it either to download the assembly or be callable from client script. Do I
need to do anything special in the c# assembly that will get downloaded? So
far its just a normal class library.

The client machines are all IE6 and can have the framework installed on them
too.

Any help would be much appreciated.

Regards

Nov 19 '05 #1
9 2199
> I have seen loads of people asking how they can host a WinForms control in
IE but all I want to do is call a few methods in my assembly which do not
have or need a UI.
Ever wonder why you haven't seen loads of people asking about what you want
to do? There is a reason. It's not remotely possible.

It helps to understand your programming environment. Otherwise, stick to
ASP, VBScript, and VBA.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Gravy" <Gr***@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com... Hi

I want to use one of my c# assemblies on the client browser (IE), say
using
javascript to call it.

I have seen loads of people asking how they can host a WinForms control in
IE but all I want to do is call a few methods in my assembly which do not
have or need a UI.

The <object> tag seems to play a big role here but I haven't managed to
get
it either to download the assembly or be callable from client script. Do I
need to do anything special in the c# assembly that will get downloaded?
So
far its just a normal class library.

The client machines are all IE6 and can have the framework installed on
them
too.

Any help would be much appreciated.

Regards

Nov 19 '05 #2
I really hope that you didn't intend for that to sound as rude as it did.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I have seen loads of people asking how they can host a WinForms control in IE but all I want to do is call a few methods in my assembly which do not have or need a UI.
Ever wonder why you haven't seen loads of people asking about what you

want to do? There is a reason. It's not remotely possible.

It helps to understand your programming environment. Otherwise, stick to
ASP, VBScript, and VBA.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Gravy" <Gr***@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi

I want to use one of my c# assemblies on the client browser (IE), say
using
javascript to call it.

I have seen loads of people asking how they can host a WinForms control in IE but all I want to do is call a few methods in my assembly which do not have or need a UI.

The <object> tag seems to play a big role here but I haven't managed to
get
it either to download the assembly or be callable from client script. Do I need to do anything special in the c# assembly that will get downloaded?
So
far its just a normal class library.

The client machines are all IE6 and can have the framework installed on
them
too.

Any help would be much appreciated.

Regards


Nov 19 '05 #3
Hi Gravy,

I want to use one of my c# assemblies on the client browser (IE), say using
javascript to call it.


It is possible, but generally not advisable. The assembly would be
subject to CAS, and depending which zone the assembly was loaded from,
it might might have very few permissions. Also, it couldn't reference
any other assembly not reachable to the client. But, I threw togheter a
small example for you.

This the HTML code:

<html>
<script>
function ChangeCalc()
{
sum.value = simpleCalculator.Add(input1.value, input2.value);
}

</script>

<body>

<object id="simpleCalculator"
classid="http:EasyCalc.dll#EasyCalc.Calc"
<param name="Text" value="Simple Control">
</object>

<br>
<input type="text" id="input1"> +
<input type="text" id="input2"> =
<input type="text" id="sum" readonly="true">
<input type="button" value="Calc" onclick="ChangeCalc()">
<br>
</body>

</html>

And the C# code looks like this:

using System;

namespace EasyCalc
{
public class Calc
{
public Calc()
{
}

public int Add(int arg1, int arg2)
{
return arg1 + arg2;
}
}
}

The example above is runnable in the local intranet zone at the very
least (if you haven't changed any of the default permission settings on
the local intranet zone).

HTH,
Jonas

Nov 19 '05 #4
Thank you Jonas, hopefully Kevin will read your reply too!

This is was I was thinking but I never got it to work. I wasn't sure whether
the assembly I wanted to reference need any special attributes applied, like
Guids etc.

I'll give it another go anyway.

Thanks again.

"Jonas Blunck" wrote:
Hi Gravy,

I want to use one of my c# assemblies on the client browser (IE), say using
javascript to call it.


It is possible, but generally not advisable. The assembly would be
subject to CAS, and depending which zone the assembly was loaded from,
it might might have very few permissions. Also, it couldn't reference
any other assembly not reachable to the client. But, I threw togheter a
small example for you.

This the HTML code:

<html>
<script>
function ChangeCalc()
{
sum.value = simpleCalculator.Add(input1.value, input2.value);
}

</script>

<body>

<object id="simpleCalculator"
classid="http:EasyCalc.dll#EasyCalc.Calc"
<param name="Text" value="Simple Control">
</object>

<br>
<input type="text" id="input1"> +
<input type="text" id="input2"> =
<input type="text" id="sum" readonly="true">
<input type="button" value="Calc" onclick="ChangeCalc()">
<br>
</body>

</html>

And the C# code looks like this:

using System;

namespace EasyCalc
{
public class Calc
{
public Calc()
{
}

public int Add(int arg1, int arg2)
{
return arg1 + arg2;
}
}
}

The example above is runnable in the local intranet zone at the very
least (if you haven't changed any of the default permission settings on
the local intranet zone).

HTH,
Jonas

Nov 19 '05 #5
No, David, I didn't intend for it to sound rude. Thank you for your kind
response, however. I'm afraid my bedside manner is still in beta.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"David Jessee" <dj*****@houston.rr.com> wrote in message
news:On**************@tk2msftngp13.phx.gbl...
I really hope that you didn't intend for that to sound as rude as it did.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
> I have seen loads of people asking how they can host a WinForms control in > IE but all I want to do is call a few methods in my assembly which do not > have or need a UI.


Ever wonder why you haven't seen loads of people asking about what you

want
to do? There is a reason. It's not remotely possible.

It helps to understand your programming environment. Otherwise, stick to
ASP, VBScript, and VBA.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Gravy" <Gr***@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
> Hi
>
> I want to use one of my c# assemblies on the client browser (IE), say
> using
> javascript to call it.
>
> I have seen loads of people asking how they can host a WinForms control in > IE but all I want to do is call a few methods in my assembly which do not > have or need a UI.
>
> The <object> tag seems to play a big role here but I haven't managed to
> get
> it either to download the assembly or be callable from client script.
> Do I > need to do anything special in the c# assembly that will get
> downloaded?
> So
> far its just a normal class library.
>
> The client machines are all IE6 and can have the framework installed on
> them
> too.
>
> Any help would be much appreciated.
>
> Regards
>



Nov 19 '05 #6
I hope I was wrong, Gravy. But I doubt it. Let us know. I don't like being
wrong, so I appreciate finding out when I am.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Gravy" <Gr***@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
Thank you Jonas, hopefully Kevin will read your reply too!

This is was I was thinking but I never got it to work. I wasn't sure
whether
the assembly I wanted to reference need any special attributes applied,
like
Guids etc.

I'll give it another go anyway.

Thanks again.

"Jonas Blunck" wrote:
Hi Gravy,
>
> I want to use one of my c# assemblies on the client browser (IE), say
> using
> javascript to call it.
>


It is possible, but generally not advisable. The assembly would be
subject to CAS, and depending which zone the assembly was loaded from,
it might might have very few permissions. Also, it couldn't reference
any other assembly not reachable to the client. But, I threw togheter a
small example for you.

This the HTML code:

<html>
<script>
function ChangeCalc()
{
sum.value = simpleCalculator.Add(input1.value, input2.value);
}

</script>

<body>

<object id="simpleCalculator"
classid="http:EasyCalc.dll#EasyCalc.Calc"
<param name="Text" value="Simple Control">
</object>

<br>
<input type="text" id="input1"> +
<input type="text" id="input2"> =
<input type="text" id="sum" readonly="true">
<input type="button" value="Calc" onclick="ChangeCalc()">
<br>
</body>

</html>

And the C# code looks like this:

using System;

namespace EasyCalc
{
public class Calc
{
public Calc()
{
}

public int Add(int arg1, int arg2)
{
return arg1 + arg2;
}
}
}

The example above is runnable in the local intranet zone at the very
least (if you haven't changed any of the default permission settings on
the local intranet zone).

HTH,
Jonas

Nov 19 '05 #7
here's a link on this:
http://forums.devarticles.com/archive/t-4583

I think that a WinForm control added to a page this way will have
permission to call a web service at the same web site it came from. This
would seem to be similar to a Smart Client app.

I haven't tried it, though. And it may only work with IE.

Eric
Nov 19 '05 #8
Hey Guys,

Thanks for all your help. The good news is that I have a very simple example
working now. I think one think I was doing wrong in the first place is not
placing the dll (the one referenced in the object tag) in the application
folder (not the BIN folder). As soon as I put it in the same folder as the
aspx file it started working.

Now, I shall try doing some usfull work and see how far I can get.

"Eric" wrote:
here's a link on this:
http://forums.devarticles.com/archive/t-4583

I think that a WinForm control added to a page this way will have
permission to call a web service at the same web site it came from. This
would seem to be similar to a Smart Client app.

I haven't tried it, though. And it may only work with IE.

Eric

Nov 19 '05 #9
It worked ok. However, as described in the link you gave me I too had
security exceptions because my client side c# assembly wanted to call a COM
component. I had to use the framework wizards to adjust the .NET security and
give local intranet full trust.

Does anyone know if this is possible to set this setting through active
directory policy?

Thanks for all your help

Graham
"Eric" wrote:
here's a link on this:
http://forums.devarticles.com/archive/t-4583

I think that a WinForm control added to a page this way will have
permission to call a web service at the same web site it came from. This
would seem to be similar to a Smart Client app.

I haven't tried it, though. And it may only work with IE.

Eric

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ken Durden | last post by:
I'm working on a client-server application where the client is controlling two devices (aka servers) which both implement the same interface contract. We have a set of about 4 assemblies which...
1
by: Jim Hammond | last post by:
I can get data from a client-side assembly to the server in two manual steps, but I need to be able to do it in one step. Step 1: The user presses the manually coded "Step 1" button, which calls...
11
by: John Boghossian | last post by:
I know this isnīt spot on for this group, but the problem relates to an asp.net project i am working on. I am trying to develop an windows forms control to be used in IE in an intranet solution....
2
by: Andrew Bagby | last post by:
Hi, I have created a c# assembly that I want to use from IE. There is no UI, just some methods that I want to call from client-side script. I've referenced the assembly as follows: <object...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
1
by: Dejan | last post by:
Hello! I need to make an ASP.NET XML Web Service serving as an assembly container. Web Service loads the assembly from a given file, and returns that assembly to the caller. Since ASP.NET...
12
by: Steven Berkovitz | last post by:
I have several ASP.NET applications with near identical web.config files. In one of them I am successfuly able to bind to an assembly while on others I am not. All of them have the following...
3
by: DevX | last post by:
Hi to all, An ex-coworker of mine is learning ASP .NET for building web application. Because I had 3 years experience in .NET programming (but zero on web programming and ASP .NET) he asked me a...
4
by: andrei.csibi | last post by:
I've have a .NET Assembly, which is COM Visible. I would like to load objects from this assembly in javascript code. E.g. Assembly Book.dll has the class Book and I would like to use <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.