|
What exactly do you mean that you don't get an out-of-process server? It works just fine. My forte' is interoperability in .NET and I do this all the time. The example does work, and if you need a typelib the /tlb switch on regasm.exe will generate one. If you make a script file like I provided, then execute the script with the Windows Scripting Host (cscript.exe for this example). Check the task manager and you'll see the application running. The ShowDialog method defined in the explicit class interface is just one method to show in this example. If you need access to anything else (like form properties, methods, or your own class's properties and methods) then you'll need to define those in the class interface as well, or at least another dispatch interface you could implement. The CLR will take care of the rest.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I created a script file, exactly as you provided. I get a dialog box with "Out-of-Proc Server Test" in the title bar and Hello world as expected. I have checked task manager and the application I see running is cscript.exe. Is this what you mean? What application do you mean? I was expecting test.exe(the out-ofproc server exe), which is not in task manager, maybe I am missing something here. My understanding of an out of process server is "A server, implemented as an .EXE application, which runs outside the process of its client", cscript being the client in this case. I apologise for the confusion, if I have caused any. I have done this in COM, however this is the first time I have tried to do it in .NET.
|
|
|
|
|
mscoree.dll - the CLR host - creates an AppDomain for the executable and loads the assembly, executing the main entry point and marshalling calls. This does not create a separate process as you've seen. I'm not even sure you could do this using pure .NET. You might have to create your own shim (like mscoree.dll) that runs as a process and marshals calls to your managed AppDomain. I remember seeing some code once for a custom host such as this (sorry, can't remember where - though you could try SourceForge) and it was by no means a simple task.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Have a look at my plugin manager article, someone mentioned that was similar to an out of process server.
|
|
|
|
|
Leppie,
Thanks for the reply, I had a look at your plugin manager article, tried to do the same in my situation and could not get it to run out of process.
A better description of what I am trying to do might help:
I have built a COM Callable Wrapper (CCW) using Microsoft .NET & C#. The CCW uses attributes to provide a COM interface into a .NET component. This CCW can be created in-process using standard CoCreateInstance calls. However, it is necessary that this CCW runs out-of-process replacing an original COM component built using VC++ as a COM EXE service.
I have used the SDK supplied COMREG sample instead of REGASM to register the component with an AppID indicating that it should be run with a surrogate process – the system supplied surrogate DllHost.EXE.
The CCW can then be created out of process when CoCreateInstanceEx with a local COSERVERINFO address, ie, via DCOM. However, existing clients use standard CoCreateInstance to create the CCW; however standard CoCreateInstance causes the CCW to be created in-process instead of out of process.
Is their a mechanism to force the CCW to be created out-of-process (as if created using CoCreateInstanceEx) with the standard CoCreateInstance call.
I am investigating further, any further you have to add would be greatly appreciated.
Regards
Colin
|
|
|
|
|
Sorry, but my COM knowledge is worse than zero I have no need for it and it looks like too much crap for my liking.
|
|
|
|
|
I would like to play a Direct3D animation inside of a window panel. Can anyone point me in the right direction. I have nothing implemented for that so far. Is it simply a case of specifying that the panel is the Owner of the animation?
|
|
|
|
|
See the Device constructor which takes a Control as the 3rd parameter, which is uses for the rendering surface.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can anyone give me some information on the commenting schema for the self-generated doc files?
ie> /// <summary> blah </summary>
I need information on what other tags can be used, and what they are for. I can't seem to find any decent documentation on this anywheres online.
Thanks in advance,
Jon
|
|
|
|
|
|
|
You're welcome!
Regards,
Jeff Varszegi
EEEP!
|
|
|
|
|
Hi, how can I dectect when a column of listview chage its width at runtime?.
It happend When the user chage de width of the colums (Sistem.Windows.Columnheader) withe the mouse.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
Extend the ListView class and override WndProc like so (a sample application is provided):
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public class Test : Form
{
static void Main()
{
Application.Run(new Test());
}
public Test()
{
SuspendLayout();
Text = "MyListView Test";
MyListView lv = new MyListView();
Controls.Add(lv);
lv.Dock = DockStyle.Fill;
lv.View = View.Details;
lv.ColumnHeaderChanged += new ColumnHeaderChangedEventHandler(
lv_ColumnHeaderChanged);
ColumnHeader col1 = new ColumnHeader();
col1.Text = "One";
ColumnHeader col2 = new ColumnHeader();
col2.Text = "Two";
lv.Columns.Add(col1);
lv.Columns.Add(col2);
ResumeLayout();
}
private void lv_ColumnHeaderChanged(object sender,
ColumnHeaderChangedEventArgs e)
{
Console.WriteLine("Column {0} changed: new width = {1}",
e.ColumnHeader.Text, e.ColumnHeader.Width);
}
}
public class MyListView : ListView
{
private IntPtr hWndHeader;
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
hWndHeader = SendMessage(Handle, LVM_GETHEADER, 0, 0);
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_NOTIFY)
{
NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
if (hdr.hwndFrom == hWndHeader &&
(hdr.code == HDN_ITEMCHANGEDA || hdr.code == HDN_ITEMCHANGEDW))
{
NMHEADER header = (NMHEADER)
Marshal.PtrToStructure(m.LParam, typeof(NMHEADER));
int index = header.iItem;
if (index >= 0 && index < Columns.Count)
{
ColumnHeader col = Columns[index];
OnColumnHeaderChanged(new ColumnHeaderChangedEventArgs(col));
}
}
}
}
public event ColumnHeaderChangedEventHandler ColumnHeaderChanged;
protected virtual void OnColumnHeaderChanged(ColumnHeaderChangedEventArgs e)
{
if (ColumnHeaderChanged != null)
ColumnHeaderChanged(this, e);
}
private const int WM_NOTIFY = 78;
private const int HDN_ITEMCHANGEDA = -301;
private const int HDN_ITEMCHANGEDW = -321;
private const int LVM_GETHEADER = 4127;
[StructLayout(LayoutKind.Sequential)]
public class NMHDR
{
public IntPtr hwndFrom;
[MarshalAs(UnmanagedType.U4)] public int idFrom;
[MarshalAs(UnmanagedType.U4)] public int code;
}
[StructLayout(LayoutKind.Sequential)]
public class NMHEADER
{
public IntPtr hwndFrom;
[MarshalAs(UnmanagedType.U4)] public int idFrom;
[MarshalAs(UnmanagedType.U4)] public int code;
public int iItem;
public int iButton;
public IntPtr pitem;
}
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg,
int wParam, int lParam);
}
public delegate void ColumnHeaderChangedEventHandler(object sender,
ColumnHeaderChangedEventArgs e);
public class ColumnHeaderChangedEventArgs : EventArgs
{
private ColumnHeader columnHeader;
public ColumnHeaderChangedEventArgs(ColumnHeader header)
{
columnHeader = header;
}
public ColumnHeader ColumnHeader
{
get { return columnHeader; }
}
} For fun I implemented the ColumnHeaderChanged event, though you could just skip all that and implement your code where I call OnColumnHeaderChanged (which fires the event - the proper way to fire an event in order to allow derivative classes to override your event handler without handling the event itself, which is faster and allows for more control).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you!
Thats what I need. Its is very complicated for me now but works fine. I hope understand it all soon.
I will use it in my DataListView custom control.
La realidad no es más que impulsos eléctricos del cerebro - Morpheus
|
|
|
|
|
The best way to understand it is the read the documentation for the classes and members I used. Many of what I did, however, is from the Platform SDK for common controls. I re-declared several native structs as classes (not as structs as I normally would so that I can use Marshal.PtrToStructure , which requires a class instance) and P/Invoked SendMessage . The constants are defined in winuser.h and commctrl.h.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How take IP-address of workgroup or domain computers?
Demonstrate with an C# example.
Cosma
|
|
|
|
|
If you know the names of these computers use the Dns.GetHostByName method. This returns an object of class IPHostEntry which contains a list of IP addresses associated with the host.
<br />
System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostByName(hostName);<br />
System.Net.IPAddress[] adresses = hostEntry.AddressList;<br />
See the documentation for further information.
|
|
|
|
|
To show the IP Address(es) of the local computer add:
<br />
string hostName = SystemInformation.ComputerName;<br />
System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostByName(hostName);<br />
System.Net.IPAddress[] adresses = hostEntry.AddressList;<br />
foreach (System.Net.IPAddress curAdd in adresses)<br />
{<br />
MessageBox.Show(curAdd.ToString());<br />
}<br />
Sincerely,
-Ron
|
|
|
|
|
But if there are 20 computers in my local network,
and a must now how from it's are online.
confused:
|
|
|
|
|
But if there are 20 computers in my local network,
and a must know how from it's are online.
confused:
|
|
|
|
|
I use the Dns.GetHostByAddress method to determine if a computer is online. If not this method throws an exception. I'm not sure which exception this is, but it think you will find out by testing.
I think that the Dns.GetHostByName method which i mentioned shows a similar behaviour.
|
|
|
|
|
If you want the ip address of all the machines in your workgroup you will have to use a file called netapi32.dll, you will have to extract data from it.
Alternatively you could try to resolve a range of ip address and the address that get resolved could be added to an array. That array could be the list of hosts that are available in your network. You could use the Dns.GethostbyAddress method for it.
CCIE (R&S) Written, MCSE 2000 Security
|
|
|
|
|
Thanks, but how can i use this netapi32.dll in C# to know
what of network computers are online.
confused:
|
|
|
|
|
I have a base-class form with buttons on it. If I derive from this form, I want to be able to click the buttons at design time, and react to the clicks. Any ideas?
Thanks in advance.
Kyosa Jamie Nordmeyer - Cho Dan
Portland, Oregon, USA
|
|
|
|