|
If you think about it, a firewall that allows programmatic access to its setup woul be pretty daft! Virus writers could quite easily circumvent the protection of the majority of computer users.
I think the possibility of doing this (at least without local admin rights) is slim to nil.
|
|
|
|
|
|
Hi coders !
I need to binary convert a byte (unsigned 8 bit, 0 to 255) to an
sbyte (signed 8 bit, -128 to 127).
I have no problem converting an array of bytes to any other
type using BitConverter.To[type] functions, but there's no
BitConverter.ToSByte ....
VS 2003 - compact framework SP3
any ideas ?
Ciao
Marco
-- modified at 9:54 Thursday 26th January, 2006
|
|
|
|
|
You can just convert it, ignoring overflow, as there is no data loss.
byte source = -42;<br />
sbyte dest;<br />
<br />
unsafe { dest = (sbyte)source; }
---
b { font-weight: normal; }
|
|
|
|
|
Are you sure ?
First off
<br />
byte source = -42;<br />
is indeed wrong since byte is UNSIGNED (0 to 255).
Second a simple cast doesn't convert BINARY the values,
meaning a 10010011 is (let's say) 215 for a byte and
-81 for a sbyte.
still looknig for help
Ciao
Marco
|
|
|
|
|
|
Just a typo. Of course a byte can't be -42.
It was unchecked (as leppie suggested) that I was going for, not unsafe.
However, some testing reveals that you can just cast the value from byte to sbyte. You don't need unchecked mode for casting between signed and unsigned data types.
byte source = 214;<br />
sbyte dest;<br />
dest = (sbyte)source;
Now dest will contain the value -42.
Marco [Stinger] wrote: Second a simple cast doesn't convert BINARY the values
What do you mean by convert BINARY, then?
---
b { font-weight: normal; }
|
|
|
|
|
It works perfectly, I did the same test
and got the same result.
By binary I meant exaclty that : having a brunch of bits read
from the sbyte point of view (so to speak)
Thanks a LOT everyone !!!
Ciao
Marco
ps: I WANT to install vs 2005 .... it's GREAT, but I have only
1 PC and some soon to be released products in VS 2003.
.... I MUST WAIT .....
.... I MUST WAIT .....
.... I MUST WAIT .....
.... I MUST WAIT .....
|
|
|
|
|
Try to use Convert.ToSByte(source);
May be this will work.
byte source =42;
sbyte dest;
dest = convert.ToSByte(source);
|
|
|
|
|
Hello all,
I have an application that performs alot of logging, as a result of this the execution time is increase by an unnacceptable amount. Unfortunatly the logging is a necessarily evil and the volume cannot be reduced
To get around this problem I placed the logging code into a typical threadpool implementation
delegate void ThreadedLogger(int logLevel, string data, Datetime logDate);
...
...
ThreadedLogger tl = new ThreadedLogger(LogWriter);
timl.BeginInvoke(1,
"log data",
Datetime.Now,
null,
null);
...
...
void LogWriter(int logLevel, string data, Datetime logDate);
{
}
Now this all works fine, and my execution times have dramatically dropped. The problem is that if the calling application exits before the the ThreadPool has finished the remaining items in the threadstack are purge and the log is never written.
Putting a wait in the code to ensure that threadpool has finished defeats the point of threading off in the first place, so i am looking for another solution. Does anybody have any ideas on possible solutions to this problem.
|
|
|
|
|
|
I created a class library and would like in one class to keep a variable of type
System.Windows.Forms.TextBox
However for some reason in the class library the namespace System.Windows is not known. Is this normal? Did I screw up a setting somewhere?
Please help me if you know what might be wrong...
Friendly Regards,
Davy
|
|
|
|
|
Just add a reference to assembly System.Windows.Forms in your class library
|
|
|
|
|
Ok that was it... Thanks a lot!;)
I'm still new to .NET so my mind didn't go that way...
Greetings,
Davy
|
|
|
|
|
First of all.. ive posted this question in 2 other forums without any luck (or responses)
so i thought id try this great forum with lots and lots of talented people
...
Ive had some problems getting the TcpListener under C# to find and accept
connections from a client with my client app and/or a simple telnet connection.
Connecting locally (localhost / 127.0.0.1) works fine but externally does not.
First i thought that it must be a firewall that was refusing the connections,
but even with it shut off (on both the server and client) i still cant get it to connect.
Has anyone had the same problem and if so, what should i do to fix it?
Im using WinXP Pro, .NET 1.1 and VS 2003.
Heres a simplified version of how i setup the tcp listener on the server:
// Initialize the tcp listener for connection clients
TcpListener tcpServerListener = new TcpListener(IPAddress.Any, 8002);
// Start the tcp listener
tcpServerListener.Start();
// Wait for an incomming connection from a client
Socket socket = tcpServerListener.AcceptSocket();
// Handle the connected client here
|
|
|
|
|
hello first my friend iam developing the same application and i had the same problems but i will solve all your problems then.
The problem in your application is
here
<br />
TcpListener server = new TcpListener(IpAddress.Any,8002);<br />
When you use IpAddress.Any
It listens for the default ip address of your windows xp even if you are connected to the internet . So you will have to make it listen for the ip address currently in use . So you will piece of code to your previous code as the following and the same for the client don't forget
<br />
IpAddress CurrentAddress = Dns.Resolve(Dns.GetHostName).AddressList[0];<br />
IpAddress CurrentAddress = Dns.Resolve(Environement.MachineName).AddressList[0];<br />
TcpListener server = new TcpListener(CurrentAddress,8002);<br />
i developed my application and i chatted with my friends through it on the internet and it works well but the problem i face now is that i need to enable the firewall immediately during installation of my messenger in their pcs through Win32 calls to SendMessage() functions but i don't know how .
If you have any solution for this it will be appreciated from you my friend.
Mess With The Best And Die Like The Rest
|
|
|
|
|
Thanks a lot for the help!
It finally works now, although i have to configure my firewall at work to let through connections as well as with a non-firewall system.
Im not quite sure i understand your problem, but perhaps something like this is
what youre asking for?
http://msdn.microsoft.com/msdnmag/issues/03/07/NET/
http://msdn.microsoft.com/msdnmag/issues/02/08/CQA/
Again, thanks for the help!
|
|
|
|
|
Thanks my friend for your help . Any Problem faces you in network programming just buzz me and send me the problem here
snouto@gmail.com
Mess With The Best And Die Like The Rest
|
|
|
|
|
i have pointer of the method with getFunctionPointer() but how can i call method using that pointer. There are no answer on hole Net and 666MSDN
winx
|
|
|
|
|
|
I never knew about function pointer in C#, but at a guess they would return a delegate, or function signature, not the actual function itself?
|
|
|
|
|
i think there is no such concept of "Function Pointer" in C#, it might implemented as a Delegate in C#
|
|
|
|
|
there also function Marshal.getDelegateForFunctionPointer(ptr,type) in 2.0 which make delegate from functionPointer (IntPtr) obtained by RuntimeMethodHandle.getFunctionPointer. I try to call function just by its address (function pointer) and there is no any article on all web There is many on C++ DLL which is microsoft base attention ......
winx
|
|
|
|
|
Hi,
I have two assemblies, strong name signed by using the same signing key file. One assembly opens the other assembly using reflection. In order to check whether it is the original assembly (created by me) that I am opening I would like to compare the strong name key of the two applications (which is the main proof that I created the second assembly and not somebody else).
How do I do this? Assembly.GetName().GetPublicKey() seems the hash code of the assembly encrypted by de private key, instead of the public key.
Thank you,
Gidon
|
|
|
|
|