|
can any body tell me how to add a form to a panel using C#.NET.
Thanks in advance.
Reagrds:
Biswajit
biswajit nayak
|
|
|
|
|
Surely you mean add a panel to a form?
|
|
|
|
|
"Form" is inherited from "Control", so you can use panel.Controls.Add(yourForm) . But it looks strange, why you are doing this ?
|
|
|
|
|
You could use the SetParent WinAPI command (google it). However, embedding a form in a panel makes the form immune to other general window events. You will not be able to move the window or interact with the titlebar.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
I create a series of classes that inherit from a prototype class (a class with just virtual functions):
class CBlockPrototype
{
"constructor/destructor"
virtual method1,method2,... = 0;
}
class CBlock1: public CBlockPrototype [...]
class CBlock2: public CBlockPrototype [...]
[...]
I define every class in a different header file (BlockPrototype.h,Block1.h,[...]) but I find very comfortable to implement the same methods of every derived classes in the same cpp file:
method1.cpp contains
CBlock1::method1
{
}
CBlock2::method1
{
}
CBlock3::method1
{
}
[...]
method2.cpp contains
CBlock1::method2
{
}
CBlock2::method2
{
}
CBlock3::method2
{
}
[...]
I try to compile but the linker says me errors: " [...] linker error [...] CBlockX::methodY already defined in methodY.h [...]"
I hope to be clear.
Can someone help me?
Thank you
|
|
|
|
|
You should ask this in either the Visual C++ / MFC
[^] or Managed C++/CLI[^] forums (but not both). This is a .NET focused forum, not C++.
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines][ Articles][ Blog]
|
|
|
|
|
Hi All,
I am having some problems with .NET Socket Receive Method. I have a client application which I am sending data to a server app. The send works properly, the server receives it. I am expecting a response back from the server, but due to unforseen problems the server doesn't respond. My client application does not block at the Socket.Receive() and loops indefinately waiting for data. I would expect it to block (or wait a specified timeout) until either an exception is thrown (timeout, or closed socket), or data is received. Debugging the connection socket properties on the client reveals that the application thinks the socket is still Connected, and there is no data available.
I loaded up WireShark, and traced the connection. It appears that the server is initiating a shutdown, by sending a FIN packet. I see a lower level FIN ACK being sent back to the server from the client, however the application code doesn't seem to detect this. Could this be why the socket doesn't block at the Receive? Is there a way to detect that the server wishes to close the connection?
FYI, the client application is currently written in C# using .NET 3.5 framework.
Any suggestions would be greatly appreciated.
Thanks for your help in advance.
Kind Regards,
James
|
|
|
|
|
James, you did not specify your protocol or connection method.
If you are using a connection-oriented protocol, you must either call Connect to establish a remote host connection, or Accept to accept an incoming connection prior to calling Receive. The Receive method will only read data that arrives from the remote host established in the Connect or Accept method. If you are using a connectionless protocol, you can also use the ReceiveFrom method. ReceiveFrom will allow you to receive data arriving from any host.
If no data is available for reading, the Receive method will block until data is available, unless a time-out value was set by using Socket..::.ReceiveTimeout. If the time-out value was exceeded, the Receive call will throw a SocketException. If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, the Receive method will complete immediately and throw a SocketException. You can use the Available property to determine if data is available for reading. When Available is non-zero, retry the receive operation.
led mike
|
|
|
|
|
Hi Mike,
Thanks for the reply. I open the socket connection to the client as follows:
connectionSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
if (traceFlag)
{
LogMessage(Severity.ER_SEVERITY_INFO_RETURN, myFilename,
"Socket.Open(): Attempting connection to {0}:{1}", hostName, port);
}
try
{
connectionSocket.Connect(hostName, port);
}
catch (Exception ex)
{
Close();
throw ex;
}
The portion of the receive that isn't behaving is as follows:
while (bIncoming[0] != (byte)MessageWrapper.SOM)
{
tryRead = 1;
read = connectionSocket.Receive(bIncoming, 0, tryRead, SocketFlags.None);
}
The above receive loops forever, with zero bytes received. When I debug the properties of "connectionSocket" I see Connected = true and Available is 0. I would imagine this is because the server has initiated a shutdown, however, it appears the framework is not detecting it.
Hopefully the code snippet helps. Let me know if you need more info.
Thanks for your help.
Kind Regards,
James
|
|
|
|
|
I have found that timeouts and keep-alive messages are a must when using socket connections. I know this doesn't answer your question, but did you know that if you have 3 switches in between the client and the server, then the middle switch dies, and your applications will still think the connections are fine until they try to send a message? The spec. for the keep-alive of the so called connection-oriented TCP/IP is optional.
Assert(this);
|
|
|
|
|
I just tried setting "KeepAlive" socket option to true but it didn't have any affect. The bizzare part here is that the lower level (seen through the network trace) shows that the connections is being shutdown by the server. The network layer of the client responds with an acknowledgement, but the Framework doesn't seem to detect it. It is very possible, (and probable) that i am doing something wrong in my code.
I have found in the past that it is difficult to detect that a remote host has disconnected when sending data... Send always seems to succeed unless the TCP buffer is full at the network layer. The "detection" usually comes when the application tries the next receive... but alas.. not in this case...
|
|
|
|
|
Interestingly enough, your post got me thinking, and I added the bold code below.
while (bIncoming[0] != (byte)MessageWrapper.SOM)
{
tryRead = 1;
read = connectionSocket.Receive(bIncoming, 0, tryRead, SocketFlags.None);
Byte[] b = new byte[1];
b[0] = 0x30;
connectionSocket.Send(b, 1, SocketFlags.None);
}
Now, I get an exception that the host has aborted the transaction on the second time through the loop! The first receive appears to be successful, the send is successful, then the subsequent receive fails.
Any idea how to create/catch the exception without the need of a Send? The send will mess up the server when the server does decide to respond properly.
Thanks for your help.
James
|
|
|
|
|
James Smith wrote: The send will mess up the server when the server does decide to respond properly.
James Smith wrote: I would imagine this is because the server has initiated a shutdown, however, it appears the framework is not detecting it.
How is the send going to mess up the server if it already shutdown the socket which caused the whole thing to start with?
led mike
|
|
|
|
|
Hello,
I'm setting up a remoted object and was wondering about overriding the lifetime service. I overrode the method that allows me to define my own lease settings, but I was curious about what happens when I return null instead of the lease. The object is supposed to now have an infinite lifetime if you return null. So if I applied this to a Client Activated object, then every object a client makes will NEVER get garbage collected. Is this absolutely true? If so, is there a programmatic way that the client could tell the server that it is done with the object and it's OK to clean it up, even though the lifetime is set to infinite?
It just seems odd to me that if a client activates 1000 objects and then sets them to null, and heck, even shuts itself down, the server will keep those objects hanging around. I don't want to build in any kind of sponsoring or lease renewal, I just want the object to stay around without keep-alives and 1 call that says I'm done using it. If something bad happens to the client and a couple objects get left hanging around, then so be it.
Assert(this);
|
|
|
|
|
Hello,
I'm using .NET 2.0 and setting up a remoting interface for a Windows Service. I like to be in control of how other applications use the service so I wanted to specify that client applications should only use the remoted object via an interface. My question is - Can I setup a client activated object so that clients don't have to know about the object class type (beyond the interface)?
So far I have made this work for the server activated (singleton) styled remoted object. This works fine using (ISomeInterface) Activator.GetObject( SomeInterfaceType, ....), but when I try something similar with Activator.CreateInstance( SomeInterfaceType, ... ) the system complains I need a MarshalByRefObject type . I understand why it's refusing to activate the object, but I'm wondering if there is a way around this.
BTW: If you are wondering why I want to use Client activated, it's because there is a future possibility of per client session information that needs to be evaluated per call. If each client has it's own object, then the instance can contain the session information. If I had to store per client session information in a singleton it would involve a lot more management complexity (add more code to maintain, slow things down at runtime, etc..).
Assert(this);
|
|
|
|
|
Hi
How can I transform a C++.Net code to a VB.Net code?
I don't want to run a C++.Net code in Visual Basic.Net.
I can program by VB.Net and I learned this language, but now I find a code which is important for me. I want to understand this code.
can you help me?
bye
modified on Saturday, June 21, 2008 6:14 AM
|
|
|
|
|
Reza12 wrote: How can I transform a C++.Net code to a VB.Net code?
Why would you want to? I'm curious. If the C++ code is CLS Compliant, then you can run it directly in any other CLS compliant environment.
|
|
|
|
|
Hy there,my problem is this: I have a shared assembly(dll) that must be used by many applications and I don't wan't to install it in GAC,I wan't to update it manually. So i need it to be 2 directories UP of the applications(..\..\). To achieve this,I had to sign the assembly with a SNK. That wasn't a problem,the problem is that this shared assembly has satellite assemblies for 3 languages. When I run my application,it finds the shared assembly 2 directories up,but it does not find it's its satellite assembly. I noticed that it searches for the satellite next to my app satellite assemblies. Why is that? the satellite assembly should be linked to the shared assembly,so it should look for it,for culture fr for instance, in [shared_assembly_location]\fr
If any one can help me,thanks in advance.
|
|
|
|
|
Hi All,
Could some one explain the three types of JIT
Thanks in Advance
Dana
|
|
|
|
|
|
|
Simply rewording your question like this doesn't answer the question posed to you.
|
|
|
|
|
Which 3 types of JIT compilers?
|
|
|
|
|
My question Is it possible to generate report in hindi (language) format( using anything crystal report or report services of sel server) . Every thing will be in English only report language be in hindi.
|
|
|
|
|
When I select:
1) File-->New-->New Project
2) Other Languages
3) Visual C#
4) Smart Device
One of the selections is 'Windows CE 5.0'
I have installed the CE 6.x SDK, and I so see:
'Platform Builder for CE 6.0'
Have they change the names? Should'nt I also be able to install so that I see 'Windows CE 6.0' under:
1) File-->New-->New Project
2) Other Languages
3) Visual C#
4) Smart Device
If so, how? I have searched all over the web and I not been able to find the answer.
I am go to work through the book 'Microsoft Mobile Development Handbook', but my ultimate target will be an AIM processor running a .NET versin of CE 6.0.
Thanks,
|
|
|
|
|