|
Stefan Troschuetz wrote: so I didn't took a look at the documentation
There is no excuse; you should read the documentation before using something.
And you should consult it again as soon as you don't agree with the observed
behavior of it.
In the end, that is only after after careful reading and analysis, you can
start publishing messages with "strange behavior" in their subject...
|
|
|
|
|
Ok, normally I read the docs very carefully. In this case I must admit that I only read the documentation of Double.IsPositiveInfinity , since after I changed range == double.PositiveInfinity to double.IsPositiveInfinity(range) and the behavior staid the same I jumped to the conclusion that it is not a matter of doing a comparison against Double.PositiveInfinity . You're right that it is no good excuse (especially not for using Double.PositiveInfinity in the first place), but the there is still the strange behavior of Double.IsPositiveInfinity .
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
Stefan Troschuetz wrote: I read the docs very carefully
Your modified code runs fine for me; it gives "Infinity"
when running in debug under Visual 2005
when running in release under Visual 2005
and when running outside Visual 2005
|
|
|
|
|
I was afraid of something like this. It still does not work on my computer neither under VS2005 nor outside. The same result on my laptop. Maybe this is an issue of the german version only
Tested the code under framework 1.0 and 1.1 and there it runs just fine. Also I took a look at the IL code and could not find an obvious error though I must admit that I have not much experience with IL.
I'm somewhat out of ideas what to do with this
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
If I were living in a country where infinity can not be trusted,
I would emigrate the same day...
|
|
|
|
|
THX for the tip
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
The code runs fine for me (printing "Infinity") in the following situations:
Commented, Uncommented Last Line in Debug
Uncommented Last Line in Release
It does NOT work (printing "Not Infinity"), when:
Commented Last Line in Release.
Strange indeed!
|
|
|
|
|
What version of the framework is installed on your computer? Any language packs?
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
I want to write a type to a binary file, but the write method only seems to support strings... is there a way i can do this?
Cheers
FileStream fs = new FileStream("weapon.dat",FileMode.OpenOrCreate,FileAccess.ReadWrite);<br />
BinaryWriter bw = new BinaryWriter(fs);<br />
BinaryReader br = new BinaryReader(fs);<br />
<br />
bw.Seek(0, SeekOrigin.End);<br />
bw.Write(Weapon);<br />
|
|
|
|
|
Hi,
BinaryWriter.Write() has overloads for all kinds of native data types, including
int and string. Of course it does not know your class.
If you have a Weapon class, you could add a Write(BinaryWriter) method it,
that would perform a number of basic BinaryWriter.Write() calls so everything
that needs to be written gets written. And of course you would have to
also add a Read method; you might make that one static and have it return a
new instance of Weapon.
The next problem may consist of understanding you binary file; if it consists
of a number of records, each containing the data for one out of many possible
types, you must somehow decide which classe's Read must be invoked next.
One way of solving this is by adding a static bool Recognize(BinaryReader) method,
that does not modify the stream's position, but determines if the data corresponds
with that class.
And it typically is helpful to start each record with something unique,
often called an eyecatcher. It could be a single character ('W' for weapon),
an enum value, whatever. In doing so, you could have a general ReadFile() method
that peeks at the next eyecatcher, then calls the right Read() method, and
loops over this until the file is done.
|
|
|
|
|
Thanks for the quick reply (again ), it was very helpful ^^
|
|
|
|
|
Hi all,
I would like to be able to correctly determine whether I have connected to my Host before trying to login.
Everything I can think of trying has failed.
If I try connecting to 192.168.0.1 110 it says its connected, but has 0 bytes Available. Which is great, and works for valid and invalid addresses whilst debugging, but as soon as I remove all breakpoints it comes back with errors on the valid addresses.
I done a quick search, and found using a mixture of Poll and Available which unfortunately doesn't work either.
Basically I don't want any code to continue until I have a Connected and Communicating Socket.
Any idea's?
Regards
Gav
|
|
|
|
|
Gavin Roberts wrote: it comes back with errors
What errors?
What "comes back with errors"?
Gavin Roberts wrote: Basically I don't want any code to continue until I have a Connected and Communicating Socket.
Then check for the error and if present don't continue
|
|
|
|
|
Sorry. Basically I use Socket.Available to check if any data is available before continuing which whilst stepping through with a debugger, works fine as soon as I run the code with no breakpoints Socket.Available returns 0.
I am currently using Socket.Read to check but that is quite slow.
Cheers for the reply.
Gav
|
|
|
|
|
Gavin Roberts wrote: I am currently using Socket.Read to check but that is quite slow.
Slow?? Read will read quit fast when the TCP/IP stack has received the data from the remote socket. If it is "slow" then the network connection or remote server must be slow.
Under normal network and server conditions for a POP3 Server, you can do a blocking "Connect" and when that returns you can "Read" the "OK" message sent by the Server immediately. There should be no significant delay. If there is, then you have a network issue or the POP3 Server is slow.
|
|
|
|
|
I am using Socket.Connect to connect.
At the moment, I am having to use Socket.Receive to determine whether the connection is valid or not.
I was using Socket.Available, but this only seemed to work when I was stepping through each line using Visual Studio. As soon as I removed all breakpoints and allowed it to continue as normal, Socket.Available returned incorrect data, as if it hadn't enough time to populate.
Socket.Receive is slow for a invalid Connection, and i'd prefere to speed this up.
Thanks
Gav
|
|
|
|
|
Gavin Roberts wrote: Socket.Receive is slow for a invalid Connection, and i'd prefere to speed this up.
Socket.Receive is blocking which means that it will only return after it has received data or the connection has been closed.
To check if the connection is valid you will have to look at the socket options available to see if any of those help. Also you should be checking the return status of Socket.Connect to see if it connected properly and if you are not catching any exceptions around the Socket.Connect, then you will be missing information that may lead to the answer you are seeking.
An inference from the above is that the socket should be valid by the time the receive method is called.
Phil
|
|
|
|
|
Gavin Roberts wrote: I am using Socket.Connect to connect.
Ok but have you "read" the documentation[^]
You are expecting certain behavior based on "what" if you haven't read the documentation? Just guessing?
|
|
|
|
|
hi
Unrecognized attribute 'xmlns'
all i a getting an error while running a asp.net web application in visual studio 2005
please help mee
actually i did all
1) aspnet_regiis -i
2) going to properties of iis
actuallly i installed 2008 web edition and windows pre release once in between i stopped the installation then reinstalled later
from the time i stopped in between i not able to run web application please help me
byebye
|
|
|
|
|
|
in controlpanel goto adminstrative tool->iis->website->defaultwebsite->(rightclick and click properties)from the tab clickasp.net and change the version from 1.1 to 2.0 if it is not changed and try it again
prasanna muthuramalingam
|
|
|
|
|
dude
my problem is like this see the next part of my question
i have installed .net framework 3.5 version and i dont get that option in iis tab
|
|
|
|
|
Hi all,
Please i got a problem. I have a program that runs underneath to help for security. When i have another version of that program, i have to install that stealth program again, which sometimes leads to conflict.
Question: Is there a way i can check for the existence of that program on the system to know if installation should continue?
Probably something with System.Management or File.Exists()?
Thanx a lot.
Everything has its beauty but not everyone sees it.
|
|
|
|
|
Hi,
you can detect the existence of the EXE file with File.Exists() but if the app
is running, you will not be able to overwrite it.
you can detect the EXE being active by checking the running processes, e.g.
with Process.GetProcesses(). You could try to kill the process if it is running,
after making sure it is your program to begin with.
Of cource, a security app should protect itself against being killed and/or
overwritten. I have seen security apps that consist of more than one EXE that
keep watch on each other. As soon as one exe sees another part is missing,
it launches the app; if that occurs say every second (or based on a FileSystemWatcher
assuming it is fast enough), it becomes hard to manually kill it all.
|
|
|
|
|
Hi Luc,
is there not a way i can query the system registry to get a list of installed products? Cos the installation path of the EXE to be sought might be dynamic.
thanx
He who goes for revenge must first dig two graves.
|
|
|
|