|
As leppie said, there are registry hacks you can perform and TeakUI is an easy way to do it.
I wanted to add that when you start outputing so much "junk" to the console or a TraceListener (like the DefaultTraceListener which is added by default), you incur serious performance penalties. Now, I doubt they would slow your system down THAT much (alone), but it's definitely not an accurate assessment. All that occurs synchronously. If you did it asynchronously, you'll incur a negligible performance hit but in enterprise applications this added logging feature is often worth it (see the Enterprise Application Instrumentation block on http://msdn.microsoft.com[^]).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I wan't doing any tracing nor was I outputing "junk".
___________________
Forgoing antagonism and separation, one enters into the harmonious oneness of all things. Lao Tzu
|
|
|
|
|
I have recently built an application that does Active Directory searches using DirectorySearcher. I have been asked to make it only search through a few, select OUs. is it possible to specify multiple OU's for a single DirectoryEntry? If so, How?
Yes, I am the highly suggestable type.
|
|
|
|
|
basically, i have 4 directory entries, each with a different ou, and i want to use them all in the same searchroot. is this possible?
|
|
|
|
|
hi people,
I have the following code in a web form page:
<br />
private static string CreateSalt(int size)<br />
{<br />
<br />
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();<br />
byte[] buff = new byte[size];<br />
rng.GetBytes(buff);<br />
return Convert.ToBase64String(buff);<br />
}<br />
<br />
private static string CreatePasswordHash(string pwd,string salt)<br />
{<br />
string saltAndPwd = String.Concat(pwd,salt);<br />
string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd,"sha1");<br />
return hashedPassword;<br />
}<br />
I would like to be able to use these two function in a windows form program, the only problem is that i use System.Web.Security which is not available in windows forms applications. Could anyone tell me how I might get around this problem?
thanks,
talal
"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."
--Rich Cook
|
|
|
|
|
It is available. Just add it to your project references. Of course, it's not really necessary. Use the MD5CryptoServiceProvider :
private string ComputeMD5(string value)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] buffer = Encoding.UTF8.GetBytes(value);
byte[] cipher = md5.ComputeHash(buffer);
StringBuilder sb = new StringBuilder(cipher.Length * 2);
for (int i=0; i<cipher.Length; i++)
sb.Append(cipher[i].ToString("x2"));
return sb.ToString();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks, I will try that
"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."
--Rich Cook
|
|
|
|
|
i'm sorry but i'm a bit lost here, the function you sent me sends back a hash of the password, but it doesn't use the salt value I give in the functions I posted...my situation is that I am building a web application but I would like to have a windows form to be able to change the admin password in the database and then in the web site, I use the functions I posted to check the username and password of the admin by hashing the password given using the SALT key.
thanks
"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."
--Rich Cook
|
|
|
|
|
It's sample code, not a complete solution. Just concatenate the salt as you did before calling the FormsAuthentication.HashPasswordForStoringInConfigFile method.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes I'm sorry, how stupid of me...it's nearing 11pm here, ok I got it to compile now, I will test that tomorrow and see if it works in parallel with the web form and gives the same results. thanks again
"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."
--Rich Cook
|
|
|
|
|
It's MD5, a hashing standard. So long as you're salting the value and use the same characters (case-sensitive) for the value to hash, it will work. If you're taking this from user input, you might consider trimming the strings on either side before hashing, unless you wanted to accept beginning and trailing whitespace.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok, done
I have one question about this:
<br />
StringBuilder sb = new StringBuilder(cipher.Length * 2);
for (int i=0; i < cipher.Length; i++)
sb.Append(cipher[i].ToString("x2")); <br />
what does it do exactly? I am mainly asking about this ToString("x2")
"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."
--Rich Cook
|
|
|
|
|
See the documentation for Byte.ToString(String) . It formats the byte as hex using 2 characters (so that a byte is always formatted as two chars, even if less than 127). If you don't, your MD5 is invalid since the hash must be 128 bits, or 32 hex characters (representing 16 bytes).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
oh ok, I understand now, thanks.
by the way, great Dusk at Sea World photo, I love photography and this picture is very good
"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."
--Rich Cook
|
|
|
|
|
i want to built a socket program like a chating program in yahoo messanger.I want to know how i treat both modules(means is there are two threads reading & writing thread at both modules or something else?if u have some article about this ,tell me or give me some hints.
mughalali
|
|
|
|
|
There are hundreds if not thousands of examples of chat applications out there and even right here on CodeProject. Just http://www.google.com[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i want to built a socket program like a chating program in yahoo messanger.I want to know how i treat both modules(means is there are two threads reading & writing thread at both modules or something else?if u have some article about this ,tell me or give me some hints.
mughalali
|
|
|
|
|
I have a problem stopping the server process. Everything seems fine when i stop my multithreaded server, no exceptions when i shut down the application. But the server program wont stop executing. I cant find any more threads that i have forgot to abort. Still if i try to abort the CurrentThread in the end of the program i get an AbortException that cant be handled by the application. Is there something else i can try?
Michelangelo
|
|
|
|
|
Without seeing any code, all I can tell you is that to handle the seemingly uncatchable ThreadAbortException , handle the current AppDomain's AppDomain.UnhandledException event to catch ThreadAbortException s (or any others you might want caught).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I presume your server is using a thread which continually listens on a port by running it on a thread.
Currently when you close your program down the lightweight process (the thread) continues to be executed.
In the applications "closing" event you need to ensure all threads running are interrupted and cleaned up.
Dont use the STOP method as it is very bad.. you could end up with part written data for the instance of the program.
Theres a pretty complete guide here on threads:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchusingthreads.asp[^]
Which is worth a glance, but for the quick solution do this in the closing event for the main form/application:
threadinstance.Interrupt();
|
|
|
|
|
The threads you have created may be foreground threads. These threads will keep the process running until they stop. Try setting the Thread.IsBackground property to true. Once all foreground threads have stopped executing the runtime will abort all background threads automatically.
|
|
|
|
|
I'm calling one of my own dll functions in an unmanaged (C++) dll from a managed (C#) dll. I am passing an array of structures, as an [In, Out] parameter, 512 elements long. It enters the function okay, does the necessary work, then on return from the function, i.e. when you step out of the scope of the unmanaged function in the debugger, the managed side catches a System.OutOfMemoryException with no additional info.
The C++ Structure is:
<br />
struct AudioFormat<br />
{<br />
unsigned long type;<br />
<br />
wchar_t name[MAXCHARS];<br />
<br />
unsigned short formatTag;<br />
unsigned short channelCount;<br />
unsigned long samplesPerSec;<br />
unsigned long avgBytesPerSec;<br />
unsigned short blockAlign;<br />
unsigned short bitsPerSample;<br />
unsigned short additionalBytes;<br />
};<br />
The C# structure is:
<br />
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]<br />
public struct DataFormat<br />
{<br />
public MajorDataType majorType;
<br />
public string name;<br />
<br />
public ushort formatTag;<br />
public ushort channelCount;<br />
public uint samplesPerSec;<br />
public uint avgBytesPerSec;<br />
public ushort blockAlign;<br />
public ushort bitsPerSample;<br />
public ushort additionalBytes;<br />
}<br />
The C++ function declaration is:
<br />
void DSDataTranslator::FilterGraph::AllAvailableFormats(AudioFormat *availableFormatsParam, unsigned long &availableFormatsLenParam)<br />
The C# function declaration is:
<br />
[DllImport("DSDataTranslator.dll", EntryPoint = "?AllAvailableFormats@FilterGraph@DSDataTranslator@@SAXPAUAudioFormat@2@AAK@Z", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]<br />
private static extern void AllAvailableFormats([In, Out] DataFormat[] availableFormats, ref uint availableFormatsCount);<br />
The C# call is:
<br />
uint maxCount = (uint)DataTranslatorConsts.MAXFORMATS;
<br />
DataFormat[] availableAudioFormats = new DataFormat[maxCount];<br />
<br />
for(uint index = 0; index < availableAudioFormats.Length; index++)<br />
{<br />
availableAudioFormats[index].name = "";<br />
}<br />
<br />
try<br />
{<br />
AllAvailableFormats(availableAudioFormats, ref maxCount);<br />
}<br />
catch(System.NullReferenceException e)<br />
{<br />
Debug.Assert(false);<br />
}<br />
catch(System.OutOfMemoryException e)<br />
{<br />
Debug.Assert(false);<br />
}<br />
Can anybody please help as I cannot for the life of me figure out what the issue is here? I certainly know that in the catch block if I examined the contents of availableAudioFormats it's garbage, whereas before the call everything had been intialized to 0. If anymore info is required, please ask.
|
|
|
|
|
|
I've looked at the managed extensions for C++ required to instantiate structs or classes in C#, I believe you use __gc, but unfortunately the method is declared as static in the .h file so it's not required and hence no joy there. Thanks for the reply though, and I do intend to try using __gc later on in my development. In fact I'll give it a go anyway to see what happens. Also, you might be interested to know that if I increase the array size to 4096 (rather large, I know but it is to cover all the different possible codecs and formats that a system might have installed) the exception caught is NullReferenceException.
|
|
|
|
|
The problem has nothing to do with Managed C++ extensions since you're P/Invoking the method from C#. I'm not sure what you were trying to get at, really.
If the native method is declared as static, then off-hand I really don't see what's wrong. Your declarations look correct, except that you're not declaring a fixed size for your string field. See the MarshalAsAttribute documentation for different ways of doing this, like using the SizeConst and setting that to the value of MAXCHARS you used in your native declaration.
Microsoft MVP, Visual C#
My Articles
|
|
|
|