?

Log in

No account? Create an account
ActiveX and C# --- help? - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

ActiveX and C# --- help? [May. 18th, 2004|01:47 pm]
Brad Fitzpatrick
Unix guy needs help....

How do I write an ActiveX(?) control using C#?

Basically I want what I know as a Java applet to work in MSIE, without the user needing to install anything.

I know C#. I have the .NET SDK in Win2k (under vmware) and I have Mono. I don't want to buy Visual Studio.

Help?
LinkReply

Comments:
[User Picture]From: j7xz49br3m93xrr
2004-05-18 01:56 pm (UTC)
A nice GPL alternative to Visual Studio.. :-) Make sure you had the .NET 1.1 SDK (rather than 1.0) and then download #Develop, it's a free development environment for .NET on Windows supporting C# and VB.NET through the SDK.. debugging features, etc. I'm not really a .NET developer so can't help you on the ActiveX question, although there is a wizard/template in #Develop to create 'controls'.. which might be along the lines. #Develop has a nice SDK help interface too, so at least it'd be easier finding some answers :-) Best of luck.
(Reply) (Thread)
[User Picture]From: brad
2004-05-18 01:58 pm (UTC)
Oh, I should've thought of that.

There's a fork for Unix called MonoDevelop.
(Reply) (Parent) (Thread)
(Deleted comment)
[User Picture]From: mcfnord
2004-05-18 02:48 pm (UTC)
The ui restrictions on code running through internet are severe, but I haven't tried hosting Windows.Forms within I.E. Thanks for the tip.
(Reply) (Parent) (Thread)
[User Picture]From: mart
2004-05-18 04:46 pm (UTC)

Writing a Windows.Forms application with Microsoft's free C# compiler (part of the .NET framework SDK) is pretty easy. You just need to write the stuff that VisualStudio.NET would write for you, which is basically just a bunch of constructors and an add in a subclass of a container much like Java Swing.

I've no idea what you'd do under Mono, but I assume the code would be identical assuming the relevant classes and methods are available in Mono's implementations of Windows.Forms.

(Reply) (Parent) (Thread)
[User Picture]From: iamo
2004-05-18 02:45 pm (UTC)
As said above, one doesn't typically write an AX component in C#. .NET has its own interop stuff that isn't really the same as COM.

I think if you want to have it run on IE without any kind of extra installation at all, it's going to have to be native. .net is still new enough that most people don't have it installed, and it's a 20MB+ download for the redistributable.
(Reply) (Thread)
[User Picture]From: supersat
2004-05-18 03:20 pm (UTC)
I'm sure it's possible with COM Interop (ActiveX objects are just COM objects with a certain set of interfaces), but it wouldn't be worth it. You'd need the .net runtime on every machine it ran on, and by then you might as well use windows forms controls.

You *MIGHT* be able to compile the MSIL code into x86 (using a tool provided by MS), link it to any .net dependencies, strip out the MSIL, and distribute it, but that's a lot of work and I'm not sure it's ever been tried before (or even possible).
(Reply) (Parent) (Thread)
[User Picture]From: iamo
2004-05-18 03:29 pm (UTC)
Hm, I didn't think of the native converter. You're still stuck with a bunch of dll dependencies with it, though, I think. I'm not sure how far you can go with including extra deps in a .cab file, so maybe it's still possible.

Be a big mess though, that's for sure.
(Reply) (Parent) (Thread)
[User Picture]From: jarodrussell
2004-05-18 02:51 pm (UTC)
WebMatrix maybe?
(Reply) (Thread)
[User Picture]From: youngoat
2004-05-18 03:03 pm (UTC)
A while back I wrote a little mandelbrot fractal explorer with Windows Forms in .Net and stuck it in a web-accessible directory. I noticed later that if I went to the URL, the app just opened up. I didn't have to download/install anything. It was pretty cool. (It was running in a sandbox of course.)

http://www.ljbox.com/youngoat/misc/FractalExplore.exe

Not sure if this will suffice for your purposes. I don't know about embedding a winforms application in a webpage.
(Reply) (Thread)
[User Picture]From: mart
2004-05-18 04:07 pm (UTC)

I know you already know Java (S2 compiler) so what are you doing that can't work with AWT in a Java applet?

I'm sure you'd be doing something majorly interesting before you'd consider a Microsoft-only solution…

(Reply) (Thread)
[User Picture]From: brad
2004-05-18 04:36 pm (UTC)
FB upload client.

Even if we force a flush of a new HTML page out to the client while they do a typical web upload, the browsers don't render it until their uploads are done. Laaame.
(Reply) (Parent) (Thread)
[User Picture]From: mart
2004-05-18 04:41 pm (UTC)

A Java applet can do this, right? I've not played much with applets, but my understanding is that they can attempt socket connections back to the server which served the applet under the standard security rules. The sockets stuff has been in Java forever, and if you stick to AWT it'll work basically everywhere. .NET on the other hand will only work in IE for people who have explicitly installed the .NET runtime.

I have the .NET framework SDK installed but I don't use IE, so this would be useless to me. I also know several Windows XP users who aren't computer people who don't have .NET installed. It seems that most people who would have .NET installed are sensible enough to realise that IE is junk and people who don't will usually not have the .NET runtimes installed. That might be a gross over-generalisation but I'm sure it holds true in a lot of cases. That's before you even consider Mac users!

The choice seems obvious to me.

(Reply) (Parent) (Thread)
[User Picture]From: mge
2004-05-18 05:00 pm (UTC)

You can talk back to the server

But I don't think you're alowed to break out of the sandbox and access local files under the defaults. Atleast not without some serious prompting of the user.
(Reply) (Parent) (Thread)
[User Picture]From: iamo
2004-05-18 09:51 pm (UTC)

Re: You can talk back to the server

I'm pretty sure the same is true of .net assemblies loaded from web pages.
(Reply) (Parent) (Thread)
[User Picture]From: brad
2004-05-18 10:35 pm (UTC)

Re: You can talk back to the server

I'm thinking of those dialogs that come up and say "You want to let this program take over your computer? If you don't click yes, you won't be able to play this fun game."
(Reply) (Parent) (Thread)
[User Picture]From: brad
2004-05-18 05:31 pm (UTC)
Ignoring the local file access problem that mge pointed out, most Windows users nowadays don't even have Java installed.

But I agree Java is the right thing to do for Mac users.

Java on Linux sucks (at least on Debian) because it's non-Free.

Really, everything sucks. I can't wait for a shift to standardized fat clients.
(Reply) (Parent) (Thread)
[User Picture]From: supersat
2004-05-18 11:36 pm (UTC)
I imagine you could make something that only relies on javascript and dhtml. The upload page could be split into two frames, with one hidden. When you click submit, a javascript function changes the look of the main frame (to something like, "uploading... please wait", with a progress bar), causes the hidden frame to go to a special URL that monitors the progress of the uploads, and flushes out javascript code that updates the progress bar in the main frame, and starts the form submission in the main frame. Very hackish, but it might just work.
(Reply) (Parent) (Thread)
From: melusina_shadow
2004-05-19 12:29 am (UTC)
"and I have Mono"



::giggles::
(Reply) (Thread)
[User Picture]From: youngoat
2004-05-19 10:35 am (UTC)

Hosting .NET Windows Forms Controls in IE

I just stumbled upon this while googling for something else...
Hosting .NET Windows Forms Controls in IE
(Reply) (Thread)
[User Picture]From: brad
2004-05-20 09:50 am (UTC)

Re: Hosting .NET Windows Forms Controls in IE

I can't get it to work with IE6 and Win2k SP 4. I have the .NET 1.1 runtime and SDK installed. I even added my site as a trusted site.

Does it work for you?
(Reply) (Parent) (Thread)
[User Picture]From: youngoat
2004-05-20 11:54 am (UTC)

Re: Hosting .NET Windows Forms Controls in IE

I didn't try it. I just happened upon the link by accident. If I have time I'll play with it tonight or this weekend maybe.
(Reply) (Parent) (Thread)
[User Picture]From: youngoat
2004-07-31 04:27 pm (UTC)

Re: Hosting .NET Windows Forms Controls in IE

So, by "tonight or this weekend" I meant "never" Hope you don't mind. =]
(Reply) (Parent) (Thread)