|
Regards,
I need a well knowledged buddy discuss me runtime type member(method, property) access using System.Reflection, from performance point of view and memory usage.
I need a comparison with direct develop-time type invoke.
any benchmark or any explanation is appreciated,
Thanks
---
limit nSun = God
n → ∞
|
|
|
|
|
Reflection is generally slow. There is an article somewhere on MSDN comparing various performances. Sorry no link to it.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Ok sure it is rather slow for he first use, but doesn't .NET framework perform some approach for example some sort of cashing to speed it up for second and later invokes?
---
limit nSun = God
n → ∞
|
|
|
|
|
I would think so, although i havent really looked at it explicitly. Generally there will still be a similar overhead as with delegates which is genrally 8 - 10 times slower than a normal non-virtual call. For maximum speed I recommend using an interface.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
When I try to use a web service on a computer that connects to the Internet through a router, I get this exception:
System.Net.WebException: The operation has timed-out.
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WebTest.com.dacris.www.DBAccess.Select(String query)
at WebTest.Form1.button1_Click(Object sender, EventArgs e)
Does anyone know why this might occur and how I could fix it?
Thanks in advance.
I have a symbiotic relationship with my computer.
|
|
|
|
|
Well, my first guess would be that the web service method is timing out! Also, everything connects to the Internet through a router. Is this web service behind a proxy, or is your client behind a proxy? In some cases, SOAP messages will not work through proxies if not configured right (the client request, that is).
I see you're using a database from the calls you're making. It's possible that the query is accessing large amounts of data and is taking longer than the response timeout. In making the request (using the HttpWebRequest ), you can increase the timeout by setting the Timeout property to something higher than the default (which is, oddly enough, 100 seconds).
-----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-----
|
|
|
|
|
Heath Stewart wrote:
Well, my first guess would be that the web service method is timing out!
Well, I've tried calling other web services and methods. Some methods have nothing to do with data access. I've even tried Google's APIs.
Heath Stewart wrote:
Is this web service behind a proxy, or is your client behind a proxy?
The client is where the problem occurs, but the client is not behind a proxy.
The server doesn't matter. As I said, I tried Google's web service, and it too does not work. The error message is the same.
Heath Stewart wrote:
In some cases, SOAP messages will not work through proxies if not configured right (the client request, that is).
How might they be configured incorrectly?
Heath Stewart wrote:
you can increase the timeout by setting the Timeout property to something higher than the default (which is, oddly enough, 100 seconds).
I've tried this to no avail. I tried a timeout of 300 seconds and it still generated the same error message.
I have a symbiotic relationship with my computer.
|
|
|
|
|
dacris wrote:
How might they be configured incorrectly?
If the Proxy property is not correctly set on the HttpWebRequest , the request is most likely going to fail.
-----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-----
|
|
|
|
|
OK. So what do I set the Proxy property to if I'm not using a proxy server? Would it be the IP address of the router? And what about the login information?
I have a symbiotic relationship with my computer.
|
|
|
|
|
That is to be set only if you're using a proxy, otherwise don't mess with it. You said you're not using a proxy, so other than checking the domain restrictions on the computers in your test lab, I really don't know what to tell you.
Have you tried running the app as a privileged user in the test lab, like some domain admin or the local computer admin? Even with such elevated permissions, the local or domain security policy might be disallowing certain things that are necessary.
-----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 need an advice.
I am trying to create a multipeer system where one peer could accept multiple connections from others and should be able to make multiple connections to others.
What should I use?
- Only Threads.
- Array Lits of sockets controlling it with Select() Method.
Does anyone have a multipeer-to-multipeer code sample?
Thanks in advanced
Mario
|
|
|
|
|
ComponentDesigner.OnSetComponentDefaults() executes only when the component is dropped on a windows form. In case of a web form it does not execute. Although the designer object is constructed in both cases. This looks like a framework/IDE bug to me.
|
|
|
|
|
Hello all at CodeProject,
DataGrid customization...... I am building a DataGrid for
displaying some values in a DataSet. I am able to:
- resize last visible column to fill the entire client area of the DataGrid
- Hide and redisplay columns by using ContextMenu
- Filter the DataGrid with use of a filter expression
The next thing on my list, is wrapping text in DataGridTextBoxColumns.
I am able to resize all the cells by overriding some methods
of a DataGridTextBoxColumn(GetMinimumHeight, GetPreferredHeight), but
this makes all the rows the same height.
I want to wrap text and resize the cell to fit per individual row.
Is there anybody out there that knows how to do this?
(or maybe Microsoft would like to replace it's DataGrid with one that
does not suck.)
Thx, Wouter van Vugt
|
|
|
|
|
Does anyone know how to tell if an icon oject has been given a value.
Even if I set the object to null as shown below, the object is still set to undefined. So if I use the following code I get an error:
System.Drawing.Icon objIcon = null;
if(objIcon != null)
{
}
I am starting to think that the only way to do this is to add a Try\Catch for this error.
Any Suggestions?
Thanks Heaps.
|
|
|
|
|
Dose any body know who to program a devise which attached to the USB Port in c# ???
Mhmoud Rawas
------------
Software Eng.
|
|
|
|
|
In MDI, I know how to merge child form menu with the parent menu, does any body has any idea of how to do the same for toolbars? I would really appreciate any help regarding this.
|
|
|
|
|
I have searching for a long time but i get noting. Who can help me??? Thanks a Lot!!!
|
|
|
|
|
There's no easy way with System.Windows.Forms.ToolBar . You could try overriding WndProc and drawing a background image for WM_ERASEBKGRND , but you'd probably just be better off getting a better toolbar. Search the CodeProject web site. There are a lot of examples. You can also find many commercial products, but just understand that the ToolBar class in the .NET BCL is pretty basic and changing it would require about as much (if not more) than just writing one from scratch.
-----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 want to post some data to a web server to implement such functions:
Use a c# client to automatic login a website and get some information.
I can easily get a web page from a server by the WebRequest class,but when I want to post the username and password I really dont know how to post it.
|
|
|
|
|
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?
|
|
|
|