|
I can't believe I've spent half a day surfing and reading and still haven't figured this out.
What is the .Net equivallent of coding a VISUAL COMPONENT meant to run IN THE BROWSER. Nothing server-side, purely client-side. The server will be a simple, static HTML vending server, no ISS.
What I need to do is the following, it should be simple, but seems impossible!!!
- I need to place a legacy ActiveX control on a web page.
- I need to author, in C#, a component which runs IN THE BROWSER and accesses the ActiveX component, through COM/Intertop generated assemblies (I'm hoping that if I just toss the interop dll's into the same cab as the compoent and it'll just work).
Problem #1: I can't even figure out what the heck the .Net equivalent of an ActiveX control is, for running in the browser. At first it seemed like WebControls...but those have "runat=server"? Can somebody point me to some sample code, anywhere?
I've coded up a simple WebControl, but can't figure out if it's the right best, and if it is even how to insert it into a HTML page! The samples I've found show them going into asp pages as script, that's not what I want obviously. I'm wondering if I am supposed to be using a regular .Net Framework Component and IE can host it? I only need IE support. Can IE6 support .Net framework components?
Problem #2: Once I get the above working, it needs to be able to reference an ActiveX control which is also on the same page. How do I do this? Can I write some script in the webpage that "passes" the activeX control into the .net control? can the .net control enumerate items on the page and find it that way? How is this done, if at all?
Thanks in advance, I've been stuck on this for far too long.
Rhino
|
|
|
|
|
I could be wrong but I haven't seen "Creating a COM object in C#". I've seen C# wrappers for existing COM objects and using COM objects from C# but not creating COM objects in C#.
I believe you'll have to use either VB or C++ to create an ActiveX/COM object.
A WebControl in C# is something that generates HTML output and runs server side. It's not the same as an ActiveX which typically runs client side.
Todd Smith
|
|
|
|
|
It is quite possible to expose .NET objects as COM objects. Chris Sells does this with his CollectionGen utility[^].
By default all types are exposed to COM, but this can be changed by applying the ComVisible(false) attribute to the assembly, class, method, field, or property.
That said, .NET doesn't really replace ActiveX in the browser it just provides another way of doing it.
Now if he wanted to show a user control inside the browser, that is possible; but I'm not sure how its done (this is the only supported way of using a .NET control in an ActiveX container).
From what he said though I think he wants an activex control that will output HTML from his input. It should be possible but you still have to go through all the work involved of implementing the correct interfaces.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
If you plan to code a control that will run on the client's computer using any of the languages in .NET or the .NET framework, then the client side will have to have .NET installed for it to be able to work. You cannot code Active-X type controls for Win32 with the .NET tools.
Rocky Moore
|
|
|
|
|
I understand that I can't code ActiveX components with .Net. I understand that users will have to have the framework installed.
I guess I wasn't clear.
What I'm asking is what in .net framework is REPLACING our old abiliity to code activeX controls in the browser, so we can have thick/rich/smart web apps? Is it .Net Framework Components? Is it Windows Forms? I've learned (the hard way) that it is not WebControls, even though the name seems 100% accurate.
I would think that a visual .Net Framework Component / Control would be the answer, that seems to be the most direct replacement of the ActiveX control, but I can't figure out how to embed one in a browser.
I did find a way to embed a Windows Form in a browser, this seems to be the "replacement" I've been looking for, but there is no way that I've found to pass it in an ActiveX control via JS (or no way for it to find it itself), yet it is 100% able to host them itself. Either I'm missing something, or this seems like an interoperability / design deficiency.
Ryan
|
|
|
|
|
There is no "replacement" for ActiveX controls in .NET. A lot of .NET is designed just to make web programming easier/better/faster.
A Windows Form is just using IE/HTML to create a GUI instead of using MFC or Win32.
Maybe if you explained what problem you're trying to solve we could be of more assistance. At the moment it doesn't sound like .NET fits your needs.
Todd Smith
|
|
|
|
|
Todd Smith wrote:
A Windows Form is just using IE/HTML to create a GUI instead of using MFC or Win32.
Actually a Windows form *is* a Win32 window complete with a message pump provided by Application.Run .
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I got close by trying a worksaround, but it's not quite working unfortunately. I got the idea from here:
http://msdn.microsoft.com/msdnmag/issues/02/07/NetSmartClients/default.asp
What I did was create a Windows Form which has the Active X instance on it. It actually works for some ActiveX controls, unfortunately the one I need can't be created when running under IEExec.exe due to threading model issue, it throws and IllegalThreadStateException or some such:
"Additional information: Could not instantiate ActiveX control 'fa13a9fa-ca9b-11d2-9780-00104b242ea3' because the current thread is not in a single-threaded apartment."
Does anybody know how to work around this latest snag? The .exe runs fine normally, but not through IE / IEExec.exe. Altering the threading model of the ActiveX is not an option, it's a vendors and I don't have the source.
So far what I've done is really easy, just build any old Windows Form application, then put the exe and all required associated assemblies up on a webserver. IE 5.5/6.0 can launch it directly and run via IEExec.exe, as long as .Net framework is installed.
Thanks,
Ryan
|
|
|
|
|
I GOT IT ALL WORKING!!!
I had to manage the thread creation myself, IEExec.exe does not honor the STAThread attribute.
So basically I have a .Net Windows Form application, running in the browser (sorta), hosting a legacy ActiveX control, and it all works.
Thanks for all the help.
Ryan
|
|
|
|
|
|
I have a button.I want to define shortcut key for it.For example (shift+a) or (alt+a).How can I do it?
Thanks
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
|
I think there should be easier solution.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
I want to write some unicode(farsi) into my SQLServer database from my c# application.When I write them in my app they are ok but after they are written in SQL ? apear instead of them.
Any idea?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Solved.I have to change my collation in SQL.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
OK - i understand what attributes are, and what they allow you to do, but i cant think of a situation in which they would be benifitial.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Attributes allow you to specify extra information about a class or its members without making that stuff part of the interface.
The PropertyGrid control, for example, uses attributes to know what Category to place each property in, by examining the CategoryAttribute on the property.
The usage is wide open... and it's just up to you to come up with new and interesting ways to make it benefit you.
|
|
|
|
|
OK the code below is puzzling me. i have this nice little static member that loads pluggins based on a Type object. It does all of this fine, gets everything I want, yada yada... then i get to using the object. I'm looking at the autos in the debugger right now and they say that pluggin, by itself, is of type SourceControl.SourceSafe, which DOES implement ISourceControlPluggin (these are my classes/interfaces) though it won't let me do the cast - keeps yelling at me. Anyone have anything - i'm sure i'm just being blinded by the weekend...
object[] pluggins = System.Pluggins.Pluggins.LoadPluggins( plugginsDir, typeof(ISourceControlPluggin) );
foreach(object pluggin in pluggins)
{
MessageBox.Show( this, ((ISourceControlPluggin)pluggin).Name );
}
|
|
|
|
|
I think that we are going to need more details on what the "LoadPluggings" function is doing, maybe then we can help...
|
|
|
|
|
This is the load pluggins static member. It is really the same thing as in the MYrc example that leppie mentions.
public static object[] LoadPluggins( string Directory, Type Interface )
foreach( file found, load the assembly)...
{
if( asm != null )
{
Type[] types = asm.GetTypes();
foreach(Type type in types)
{
Type[] interfaces = type.GetInterfaces();
if( type.GetInterface(Interface.FullName) != null)
{
lstPluggins.Add( Activator.CreateInstance(type) );
}
}
}
}
}
return lstPluggins.ToArray();
|
|
|
|
|
I've noticed that same type of behavior, but mostly when working in design-time mode (as part of a custom designer). The problem seems to stem from having the two objects be created from non-identical assemblies.
Say you have a class MyClass that is compiled into MyAsm.dll. You compile code linked against v1.0.0.1 of MyAsm.dll, and this code loads code via Reflection that links to MyAsm.dll v1.0.0.2. Then you call into the code you loaded and it creates an instance of MyClass v1.0.0.2. Your code is compiled as referring to MyClass v1.0.0.1. When you try and set your reference variable (of type MyClass v1.0.0.1) to the instance of MyClass v1.0.0.2, you'll get an 'invalid cast exception'.
If indeed you are getting an "Invalid cast exception", modify the code a little bit to get a Type object for the object instance you loaded. Compare this in the debugger with
'typeof(ISourceControlPluggin)' to see if there are any minute differences.
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
Huh, you might have it. I've actually changed the output directory for the Build of the class that implements the interface to be a sub directory of the class using it. This is so that loading the pluggin assemblies involves moving them to the subdirectory of the app. I'll take a look, but that is great point.
|
|
|
|
|
Hi,
How to catch the WM_ACTIVATEAPP message in C# application with GUI? I am looking for .Net framework equivalent of CWnd::OnActivateApp function in MFC.
Thanks!
|
|
|
|
|
I just did it 5 minutes back (what a coincidence). There is no equivalent of this in C#. Here is a code snippet from my class:-
const int WM_ACTIVATEAPP = 0x001C;
protected override void WndProc(ref Message m)
{
if ((m.Msg == WM_ACTIVATEAPP) && (m.WParam == IntPtr.Zero))
{
//OnDeactivateApp(EventArgs.Empty);
}
else
base.WndProc(ref m);
}
Step back, rub your eyes, take a deep breath, stretch a bit, and reflect on the relative importance of CP, CG, the age / travel time sustained by supposedly 'fresh' cheese curds, and Life in General. - Shog9
|
|
|
|
|
Is there any place in .NET where there is a Enum of the Windows Commands that can be sent? Instead of having to go through and print out their values and defining them as constants( as above)?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|