|
Use WebRequest.GetRequestStream . You must set the Content-Type of the WebRequest before getting the stream to either "application/x-www-form-urlencoded" (and post the "key1=value1&key2=value2..." encoding like in GET requests) or "alternative/form-data" if you plan on posting files in MIME message. To just post a username and password, use the first option.
To see a good example, see the .NET SDK documentation for the WebRequest.GetRequestStream method.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
|
Hi, i have one - i think only for me - problem, i try to write some code to decode user definition code for describing user fields it's look like this ex.:
name;start;length;vaildate;validate_sub
----------------------------------------
ID;0;5;false;;
ShipDate;0;8;true;ValidateDate();
so, the point of problem is how, and if it is possible, to call te sub ValidateDate() (it's user function) via string variable? ex.:
CallSub("ValidateDate()");
please help me,
Kris (krzysztofo@poczta.onet.pl)
|
|
|
|
|
Read-up on .NET Reflection. You can do this but you'll need to know a class on which these "functions" (technically, "methods" when talked about in OOP) are attached. For example, if the various methods are on the class that reads this file, when the parsing method comes to that delimited field it could do something like this:
MethodInfo method = this.GetType().GetMethod("ValidateDate",
BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Public);
if (method != null) method.Invoke(this, null); Of course, you'll want to use a variable for the method name in the call to GetMethod , but this is the idea. You can also play around with the BindingFlags to get what you want.
You could also have a class with nothing more than validation functions and get its Type in order to call these methods. If you want static methods, that is possible with the BindingFlags too. Just read the documentation about the various classes, methods, and enums I used and read-up in Reflection.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thx, it was realy help me
KrisPL
krzysztofo@poczta.onet.pl
|
|
|
|
|
I have a problem I have been struggling with for 3 days now. In my application I have some network connection. The client and server sends some data back and forth with no problem at all in the beginning. Both the client and server have a thread to deal with the network stuff. The initialization works fine when the client and server reads passwords and such. Then both the server and client goes into a loop where they wait for a command from the other. These commands never reach their destination. The initialization and the loop is in the same function. I create a NetworkStream from the TcpClient and a StreamReader and StreamWriter from the NetworkStream. These are created directly after the initialization of the connection and are visible in the entire method. In the loop I use a StreamReader.Peek() check to see when a command is available. The Peek method never finds anything to read. In both the server and the client I use the exact same objects that worked without any problems during the initialization in the same methods.
Does anyone have any idea why this isnt working? Is there anything I have missed about network streams?
|
|
|
|
|
Try to use the read() method it will hang the thread untill it found data on the stream to read , use it without peek method
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
IS there any difference between ReadLine and Read on that point? I thought both hung the thread. I removed the peek and the problem is still there.
Thanks anyway.
|
|
|
|
|
Try use the flush method...
|
|
|
|
|
Well...
The problem turned out to be a boolean set to true instead of false meaning that one thread should abort and kill the network connection. Why I didnt get any exceptions I dont understand.
Sorry to bother you.
|
|
|
|
|
I'm wanting to be able to get a Type object from a string typename. At first glance, this looks easy: just use Type.GetType() - and this has worked for me until now. But Type.GetType("fulltypename, assemblyname") doesn't seem to work with types that reside in an assembly in the GAC - in my test case, System.Drawing.Point .
I've tried this both with and without the assembly being included in the name ("System.Drawing.Point" and "System.Drawing.Point, System.Drawing"). It works with "System.Drawing.Point, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", but I'd MUCH prefer not to have to do this, because then if the version of the .NET framework changes, the type string will have to change, too. Is there a way that I can simply get a type from a typename without having to specify a version?
|
|
|
|
|
|
leppie wrote:
I think Type.LoadFromPartialName()
Alas, I've found no such method. There's an Assembly.LoadWithPartialName() method, but nothing like it for Type .
|
|
|
|
|
|
Hi..
I have a question on Crystal reports, how to pass an output stream (e.g. an array of data) to an attached crystal report viewer bound with a crystal report object.
I have read about binding already designed report objects to crystal viewers but i want my program to interact with the report at run time by exchanging data.
Thanks on advance,
|
|
|
|
|
I use several library here in my project. Right now, I need distribute my project for binary format. How to put those license in?
Thanks.
|
|
|
|
|
Licenses should never be embedded in the executable - you'll need to compile a different application for each licensed user! The best way is to have a separate license file. .NET does have support for licensing components. See the LicenseProvider in the .NET Framework SDK documentation to get you started.
You could also check out my article Using XML Digital Signatures for Application Licensing which gives some more insight. If you don't want to code all this yourself, someone posted a link to a company called XHEO that has a nice product that incorporates the same ideas (which are commonly used in many things and is, in essence, similar to DRM).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am looking for some sample program that will accept key strokes and then send them to another running program like Notepad. Does anyone have any sample that I can use as a starting point ? Ideally, I would like to identify the target program using mouse click or automatically by Window title. Also, being able to select and replace the entire text in the target window will be great. Also can I send mouse moves to the target window ? Too many questions, I know. Please help. Thanks much..
JX
|
|
|
|
|
Quick question, does anyone know of a way to have a single string with different fonts and or sizes within that string?
Thanks,
Ryan
|
|
|
|
|
The string object holds no formatting just character data.
|
|
|
|
|
Hi Ryan. What are you looking to do? As Daniel mentioned, a string object contains no formatting itself - if you can elaborate on what you would like to accomplish, it might be easier to provide some help.
|
|
|
|
|
Sorry for the lack of explanation. I have a control that takes a string value. I blanked out there for a minute thinking that the string was holding formatting info, I ended up splitting the control and adding seperate strings to the seperate controls. But thanks for the replys!
Ryan
|
|
|
|
|
|
Hi.
I want to let the user choose with a checkbox during installation if a shortcut should be added to the desktop.
How du I do that??
I found out how to add the checkbox with the question and how to add a shortcut, but a cannot figure out how to connect the two...
also, how can i let the user choose where to place a shortcut in the user's program menu?
|
|
|
|
|
The checkbox must be bound to a property. The shortcut should have a condition property in the PropertyGrid. If it does, simply put the property name in there (the property doesn't exist initially so if it does when the condition is checked, the shortcut is created; otherwise, it's not). If it doesn't, then you'll either need to get a REAL Windows Installer builder (I recommend Wise Solutions' Windows Installer because it's much cheaper and easier to use than InstallShield's). The VS.NET installer projects are lame and only good for small projects that do need to do much or for internal testing. Beyond that scope, you either need to manually edit or create the MSI packages using Orca (good understanding of Windows Installer required) or get a real package like I described above.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|