|
See an old post[^] to a similar question. Keys.CapsLock does not count as a modifier key so you need to get the actual key state. The link above shows you how to P/Invoke GetKeyState and call it (don't worry about calling native functions - many of the classes in the .NET FCL - especially all the Windows Forms controls - already do it...a lot).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hi,
I'm just starting to learn C#(and I like it) and .NET Framework, and I stared with this: I want to make a chat application. Basically, I have a server and a client, connected via sockets (all works just fine). Now, I would like the client to send some info to the server -> a serialized object (because there are many types of values in this object). The problem is that the server and the client are not the same application, and thus, deserialization doesn't work (or at least, I couldn't make it work...maybe you can help here).
This is the code I use for serialization:
MemoryStream ms = new MemoryStream();
StreamingContext stmCtx = new StreamingContext(StreamingContextStates.CrossMachine | StreamingContextStates.Persistence);
BinaryFormatter bf = new BinaryFormatter(null, stmCtx);
bf.AssemblyFormat = FormatterAssemblyStyle.Simple;
bf.TypeFormat = FormatterTypeStyle.TypesWhenNeeded;
bf.Serialize(ms, negociate_struct);
...and then I send ms over the network. Now, serialization is basicaly ok (because if I deserialize here ms, is works fine), but on the server I got this IOException : "File or assembly name RCClient, or one of its dependencies, was not found." RCClient is my client application name. I also saved my stream to a file, and got something like:
" ˙˙˙˙ RCClient %NegociationStructures.NegociateStruct
SenderTypePacketNo
NPResponse xxx" It's obvious my server application doesn't know who RCClient is.
I figure the problem is either with setting the BinaryFormatter, or I use the wrong tool for the job. Also, I can't use SOAP serialization, because I noticed that the stream is much larger, and I need as much speed as possible (this should eventually develop into a video chat & stuff).
I hope I made my problem clear, and I would appreciate any help or hint.
Thank you in advance,
Doru K.
|
|
|
|
|
dorutzu wrote:
"File or assembly name RCClient, or one of its dependencies, was not found."
That indicates that your server application doesn't know how to find the type information for the object that your client sent over. To fix this, move all shared classes into a "Class Library" (dll) that both the client and the server applications use.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
You should also read How the Runtime Locates Assemblies[^] in the .NET Framework SDK.
Serialization does pack-up your object graph (your RCClient in this case) but it needs to deserialize it back into an instance of that class so it's still required on both ends. As the previous post mentioned, put all shared classes in an assembly that both the server and client can access and make sure it can be found.
Finally, you might want to look at .NET Remoting. It serializes data in an extensible manner (i.e., you can specify whether or not to use the binary, SOAP, or a custom formatter, and whether or not to use the HTTP, TCP, or custom transport channel) and marshals it across the wire. This also opens your application up for a good AOP (aspect-oriented programming) model so that you can intercept methods and log them, encrypt them transparently to the method calls in your program, etc. Basically, you're already doing the very basics of what Remoting is, but you'll find that Remoting is a proven, extensible, and tested implementation. Read Accessing Objects in Other Application Domains using .NET Remoting[^] also in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you very much for your answers. I took the easy way, and just bundeled everything in a .dll for both applications to use it...and it works just great! And it was so easy...
Thanks again!
Keep in touch,
Doru
|
|
|
|
|
Hey!
I have a picture(GIF) with a figure on it, it have a transparent pattern so al around this figure will be transparent.
Now this works fine if i just have this transparent picture in a picturebox right on the form, it will get the foms bakground color as bakground under the transparency.
But if i want to have a a Image as bakground and then have a picture box on top of it that contains the Gif picture(figure) then it will not show the forms bakground image in ti transparent area, instead it shows the color of the form.
Is there any way to have a picture box with a Gif above another picture and then get the bakground bickture to show throw the transparent area of the top picture(gif) ??
//Jimmy
|
|
|
|
|
Why not just draw the image onto the form without the PictureBox, that way you don't have to handle the background color of the PictureBox.
- Nick Parker My Blog
|
|
|
|
|
Yes this will solve the problem with the System Control THANKS ALOT
But
I got a own made balloon tip box in a form, this ballon tip is a picture in a panel, this balloon tip have round cornser and nedd to be transparent in this corners.
But when a choose transparent on the panles bakground it will only show the color of the forms bakground color, just like the other problem.
Do you maby got an sulotion to this to?
This panel haves som labels and so on, so i can´t just load it in to the bakground of the form like the other problem.
Yes i could load it on but then o hade to load in the cordinates for al the labels and so on, this dont sounds lika a good sulotion.
//Jimmy
|
|
|
|
|
Hi dudes,
I need to get the height of the taskbar.. How do one do that?
- Up The Irons, Morten Kristensen
|
|
|
|
|
hi, you can use the SHAppBarMessage API for that, just do a search on codeproject and theres an article on it somewhere. It will let you get the RECT structure of the taskbar.
|
|
|
|
|
Hey dude.
sorry but I can't find anything by that name.. :/
Could you be so kind to fetch it for me ?
- Up The Irons, Morten Kristensen
|
|
|
|
|
Here you go, its mostly about something else, but theres a part about getting the size of the taskbar if i remember correctly.
http://www.codeproject.com/csharp/csdoesshell3.asp
Dan
|
|
|
|
|
Every 30 seconds or so, I need my application to persist state, just in case the power goes off or something like that. What's the best method based upon this time frame? For example:
- Save to an XML configuration file.
- Save to registry.
- Save to binary file (serialize object?)
- Something better?
Thank you.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Don't save to the registry with .NET applications. It's not a good practice for many reasons, especially deployment issues. Other than that, save to whatever file format you want. Binary serialiation is faster than XML, but XML gives you the ability to easily customize the state while the program is not running.
One other way - albeit more difficult - would be to implement a custom BindingManagerBase derivative that uses a file as a backing store and bind the properties of controls you want persisted. When they change, the binding manager is updated and your derivative class could save state immediately. This way, you don't have to poll and don't have to keep a timer, which is relatively inefficient since the state of your application might not have changed. See the documentation for the BindingManagerBase and Control.DataBindings in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Another consideration for your design should be:
What happens if the power goes out WHILE the state is being saved?
If your app is that critical, you might want to consider a UPS and monitor that for a power outage so your app can save it's state one last time before the power REALLY goes out.
RageInTheMachine9532
|
|
|
|
|
Okay, it's not THAT critical
Thanks!
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Hello,
As I build MDI App, Form Activated event of each child form fires once at loading but never again. I want to know why this is happening. As earlier when same application was not MDI App Activated event of each form fires every time when form get focus.
Thanks for ur support
Inpreet Singh
|
|
|
|
|
Hello,
As I build MDI App Form Activated event of each child form fires once at loading but never again. I want to know why this is happening.
Thanks for ur support
|
|
|
|
|
i want to write an C/S based software which could capture the screen on a
remote pc and send it back.
now i can use the Win32 function to capture the screen.However,the data is too
large to pass the network(intenet).and it uses much CPU time.
i want to find a better way to capture the screen,to send the screen data with
low cost. i think that is what the PcAnywhere do on this issue.PcAnywhere can
capture the sceen many times in a second and send them back to the client ,and moreover, costs little CPU resource.
How does it work ??????
can u show me the way ?
|
|
|
|
|
I'm interesting in this question too....
can u "show me the money"(starcraft) ?
|
|
|
|
|
Actually, software such as that uses a virtual screen buffer in which the drawing is "redirected" to the remote (local for the viewer) terminal. It does not use an entire screenshot (at least, not for Remote Desktop).
I'm not sure were you could find additional information other than googling, but the Windows DDK (device development kit) might contain some more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for ur advices. then i have two questions:
1.how to compare the changes in an area ? in a 80*60 block(1/100 of 800*600),it is impossible to
detect every point. So how to get the changed area efficiently ?
2.i try to find another way on google,but there are filled of lots of softwares instead of source code samples or articles.i dont know how do they work at all.
and if DDK works,can u show me some information ?
|
|
|
|
|
Another idea is for your server app on the remote machine could monitor the desktop image for changes, comparing the current image to the last. Then when an area that has changed has been detected, send just the changes to the client on your side.
RageInTheMachine9532
|
|
|
|
|
First of all, please delete the previous my message. I made a mistake. Thanks a lot.
Question: Japanese Input Issue on a column item:
By using "click" and "click" actions (not Double click) in a TreeListView control, English can be inputted in a column, but Japanese can not be. Please show me an easy and simple way which I should do to be able to use Japanese. But in the TreeListView source, of course, Japanese can be used like the bellow,
TreeListViewItem itemA = new TreeListViewItem("JAPANESE WORD " + Enum.GetName(typeof(Drives), k), 0);
OP: Japanese Windows XP Pro.
Application: Studio.Net 2003
I am extremely happy to meet the TreeListView program written by Mr. Thomas Caudal. I have two handicaps, when asking my question, a non-native speaker of English and a non-programmer. I have been starting to study VC#, so the beginner of any programming. I can not completely understand the code. So, would you like to explain about this issue by using easy English for a beginner? Thanks a lot, if someone answer me about this question.
|
|
|
|
|