|
Hi,
I'm discovering COM programmation. I've created a client - server application in .Net.
It works fine but for each client, a new server instance is created.
I would like to create only one instance of a server on which clientS could connect to it.
This is the site who helps me to create my client server : http://my.execpc.com/~gopalan/dotnet/classic_com/com.net_quoteserver.html
Thks a lot
Denis
|
|
|
|
|
That's the way is supposed to work. It's a class and it gets created by the underlying language/framework in which the COM class was written. If it's a control, there's no way to have only a single instance parented in different containers unless you moved it around each time a container becomes visible.
If it's an out-of-process server, you can connect to only a single instance, but that article you linked (and in the future, please use an actual hyperlink - buttons below the message post text box can help you with that and it saves our time) is far, far from teaching how to do that. Hopefully you've read a lot about COM interop from Interoperating with Unmanaged Code[^] in the .NET Framework SDK. You'll need to.
Exposing a single instance out-of-proc COM server - like the various Office applications - requires that you perform the same steps you read about, but you're also going to need to declare more interfaces that are defined for COM servers and clients, as well as native APIs like CreateClassMonikder . Some interfaces are already defined for you in the System.Runtime.InteropServices namespace, like UCOMIBindCtx , but you will need to create others.
You'll want to read[^] and learn about the IRunningObjectTable (ROT), which you'd load your out-of-proc COM server's Application object's CLSID into using CreateClassMoniker to get a UCOMIMoniker and load it into the ROT using the functionality you'll be exposing using the classes and interfaces mentioned in the documented linked above. Read Exposing the Application Object[^] for more about the Application object (as it's supposed to be called, but could be anything, actually) that represents your actual out-of-process COM server (EXE).
You should read Component Object Model (General)[^] and Automation[^] in the Platform SDK for more information. .NET can work hand-in-hand with COM but there's no class library that exposes everything you need and there's still a lot of manual labor involved with accessing and exposing COM objects because it's a vastly older system that's a lot more delecate than .NET.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
We are having one application in C#.net and another application in vb 6.0,so if we want to convert the c#.net to vb 6.0 then interoptiblity is one way but is there any other way to use the C#.net code into vb 6.0?
regards.,
|
|
|
|
|
montu3377 wrote:
is there any other way to use the C#.net code into vb 6.0?
Yes, you can compile the C# code while exposing it as a COM object (in Visual Studio, see the project compiling properties. Once your C# code is visible to the COM world, it can be seen and used by VB 6.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Hallelujah! It's Ken Jennings!
Judah Himango
|
|
|
|
|
Hi,
yeah can you give me more details about urs second way.if u are having any article on that pls. send me link.
thanks
regards.,
montu3377
|
|
|
|
|
We've discussed this countless times in this forum and there are articles on this site. To search this forum, click "Search comments" above and search for "interop". For this site, every page has a text box under the logo to search for articles.
You should start learning about COM interop - and more specifically exposing .NET components to COM - by reading Exposing .NET Framework Components to COM[^] in the .NET Framework SDK.
To expose your classes and interfaces correctly, knowledge of COM is useful. Read Interface Design Rules[^]. A friend of mine - Nick Parker - also has an article that is helpful, with some comments I had him add. Read Exposing .NET Components to COM[^]. Basically, never use auto-generated class interfaces, never change published interfaces - add new ones (called versioning interfaces), and always use explicit GuidAttribute values that typically do not change for classes, and that never change for interfaces. You should also use an assembly-level GuidAttribute like so:
[assembly: Guid("Insert guid from guidgen.exe here")]
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
Do anyone has experience of developing application that sends/receives SMS (Short messaging service) to/from cell phones. If so, then please guide me how to go for it.
My goal is to develop an application in C#, where client will send their queries through SMS. Application will analyze them and reply back in SMS, the desired result.
Any idea(s)!!??
|
|
|
|
|
This site is full of articles, and a quick search on the rest of the web would yield hundreds - if not thousands - of results.
On this site, just search for SMS[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hai everybody,
I require a good security project idea in c# which includes including?
I appreciate and welcome the ideas from you. This project will be a course project at my university.
Thank you,
|
|
|
|
|
I require a good security project idea in c# which includes networking?
I appreciate and welcome the ideas from you. This project will be a course project at my university.
Thank you
|
|
|
|
|
I am creating a data table control (a user control). I have a big panel as a background panel, and divide this panel into serverl smaller panels; by adding smaller panels into the background panel control. Each child panel displays a text. I use layout event on the background panel to arrange each child panels. I got a problem.
When i try to use this control. The text in some panel doesn't display or some panels doesn't arrange correctly. However, when i close the solution and reopen again, now my control will display correctly !!!
It seems that .NET system doesn't render my control completely. But why ? I already use invalidate and any possible related method, but it doesn't produce the correct result yet .. Why ??????
Please help.
|
|
|
|
|
There's a 3rd part component on my form that keeps turning my arrow cursor into a wait cursor. Is there a way to stop this?
uh, i'm pretty sure it's the 3rd party component...
/\ |_ E X E GG
|
|
|
|
|
I'd like to use the column like the header column in DataGrid.
If I do it, I can the following action.
I create 4 columns. I set 2nd column for header column.
If I scroll the table, 1st and 2nd column fixed. And
3rd and 4th column moved.
please tell me some ideas.
regards,
yu-yu
|
|
|
|
|
HI,
I am trying to build a simple web services which simply get list of employee's last name from Sql server's database. The method in web-service class is supposed to read the data from the db and return the results in a form of DataSet and it is defined as :
---------------------------------------
//a web method which retrieves data (last names of about given
//thing in form of a data set
[WebMethod(BufferResponse=true)]
public DataSet getLastNames() {
//string var representing sql string
string sql = "";
//create a new temp dataset
DataSet ds = new DataSet();
try {
//open the connection
scConn.Open();
//create the sql
sql = "SELECT LastName FROM tblEmployees";
//create the command
cmd = new SqlCommand(sql,scConn);
//create the sql data adapter
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds,"Employees");
Console.WriteLine(ds.Tables.Count);
//clean up code
sda=null;
cmd=null;
scConn.Close();
return ds;
}
catch(Exception ex) { Console.WriteLine(ex.ToString()); }
}
----------------------------------------------------
I want to display the data from the dataset in a DataGrid (in a Windows Form) in a DataGrid. Window form also contains one button which calls webmethod and fills out datagrid. The code is given as :
---------------------------
private void cmdConnect_Click(object sender, System.EventArgs e)
{
try
{
DataSet ds = new DataSet();
localhost.wsEmployees ws = new wsEmployeesClient.localhost.wsEmployees();
ds = ws.getLastNames();
Console.WriteLine(ds.Tables[0].Rows);
}
catch(Exception ex) { Console.WriteLine(ex.ToString()); }
}
------------------------------
note localhost = name of web reference
-----------------------------------
Problem : No records can be found. There is no table in dataset.
I just want to know what i am doing WRONG. Am I missing out something either in code or IIS Server's Administration.
thanx in advance
|
|
|
|
|
Hi,
Looks like the code is ok. Try running the webservice alone and see what output you are getting. There may be some problem in accessing the database itself.
Regards
SGS
|
|
|
|
|
Uh, i was messing around and came across a problem. I have form with a timer control that runs every 10ms and I wanted it on a new thread. However, I can never get it to work.
Look at this...
public void StartMyThread()
{
Thread MyThread = new Thread(delegate()
{
timer1.Start();
});
MyThread.Start();
}
Now, why won't this have my timer run on a new thread?
/\ |_ E X E GG
|
|
|
|
|
I don't know why it's not working, is timer1 System.Threading's Timer or System.Timer's Timer?
Why do you want the timer on a separate thread? timer1.Start() is not going to block, you are going to get callbacks/events correctly even if you start the timer without creating a new thread. Any special reasons?
Regards
Senthil
My Blog
|
|
|
|
|
I want to put it on a new thread because my "tick" method is being called every 10 ms and the "thing" it does is very processor intensive and results in an un-responsive UI. When I run this code without an extra thread my CPU usgae is 100%.
/\ |_ E X E GG
|
|
|
|
|
Take this for example..
private void Form1_Load(object sender, EventArgs e)
{
Thread MyThread = new Thread(delegate()
{
timer1.Start();
}); MyThread.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Text = DateTime.Now.ToLongTimeString();
}
This builds fine. However, the timer1_Tick isn't getting called (at least it isn't putting the time in the title bar). If I take out the threading code and just leave timer1.Start(); it runs fine. How can I get the whole timer opperation onto a new thread?
An interesting note is that I am using the System.Windows.Forms.Timer timer...
/\ |_ E X E GG
|
|
|
|
|
There you go, the WindowsForms Timer requires a message loop to be running on the calling thread, that's why it never triggers the Tick event. If you start the timer from the current thread, which happens to be a thread with a message loop (because Form1_Load is called from the main application thread), it works fine. And because it works with the message loop, it can get in the way of other UI messages, that's why your UI might seem unresponsive.
I'd suggest that you use System.Threading.Timer. It doesn't use the message loop.
Anyway, if your timer triggers operations that are CPU intensive, then the usage is going to remain at 100% whether you start the Timer from this thread or a new thread. Your UI might be more responsive though, because the message loop doesn't need to process the Timer messages (which you say are very expensive) every 10ms.
Regards
Senthil
My Blog
|
|
|
|
|
Well, im using the XYgraph component, doing many graphs per second and wanted to put it on a different thread so my UI responds better, which it does.
/\ |_ E X E GG
|
|
|
|
|
Hello!
I'm trying to create a windows explorer like treeview and I've got some problems with the "System Volume Information" directory.
Everytime my code tries to work with it the UnauthorizedAccessException is thrown. I was told it is because it's a system folder or something and that I should check the directories attributes and only show the directorys that is not system folders or hidden folders.
How can I check this?
The DirectoryInfo class has the Attributes property but I can't figure out how to use it even though I have tested myDir.Attributes.ToString(); and then I've seen that some directories is hidden and system and so on.
Thanks in advance for any help!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
My propertyGrid looks a bit jumble up...
I have used [CategoryAttribute("abc")] but it is still messy.
How can i arrange my attribute(up or down) to my preperences in the property grid when it is in "categorized" view?
Thank you in advance.
|
|
|
|
|
You need to create a TypeConverter for your object and override the GetProperties() method
[TypeConverter(typeof(MyClassConverter))]<br />
public class MyClass <br />
{<br />
...<br />
}<br />
<br />
public class MyClassConverter : TypeConverter<br />
{<br />
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)<br />
{<br />
<br />
PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(typeof(MyClass), attributes);<br />
<br />
string[] s = new string[3];<br />
s[0] = "XYZPropertyName";<br />
s[1] = "ABCPropertyName";<br />
s[2] = "IJKPropertyName";<br />
<br />
return collection.Sort(s);<br />
}<br />
}
So when you look at the properties of MyClass in the property grid, they appear in the specified order
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
I assume MyClass is the propertygrid.SelectedObject class.
Then i do like what u told but the code:
string[] s = new string[3];
s[0] = "XYZPropertyName";
s[1] = "ABCPropertyName";
s[2] = "IJKPropertyName";
i follow exactly cause i don't know what is it?
My program runs the same before and after i added this code.
Please help again, i m very beginner...
Thanks so much for helping.
|
|
|
|