Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Rocco Martin
It looks like you are injecting an unnecessary step. Don't worry about encoding the resulting byte array back into a string; the constructor for Guid will be perfectly happy with the byte array. Guid guid = Guid.NewGuid(); string encoded = Convert.ToBase64String(guid.ToByteArray()); Guid reco

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Shawn Hevel
>> g = Guid(enc.GetBytes(myString1)) >> g = Guid(myString1); I figured it out. The new keyword is needed. g = new Guid(enc.GetBytes(myString1)) g = new Guid(myString1); I tried this both ways but the guids are not the same. Here is my code: Encoding enc = Encoding.ASCII; Guid guid = Guid.

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Shawn Hevel
> g = Guid(enc.GetBytes(myString1)) > g = Guid(myString1); Thanks for the advice, but what language are you using in your example. I'm programming in C#.NET and your code doesn't work. Am I missing something? Thanks, === This list is hosted by DevelopMentorĀ®

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread J. Merrill
One of these g = Guid(enc.GetBytes(myString1)) g = Guid(myString1); should construct a GUID that matches the one you started with. If neither works, you'll have to format the bytes in myString1 to produce the {...-...-...-...} format that the Guid(String) constructor might be looking for

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Hevel, Shawn
Barry, Thanks for the reply. I'm trying now to do the reverse but am a little stuck. I've tried the following but it's not getting back to the Guid I originally started out with. Encoding enc = Encoding.ASCII; string myString1 = enc.GetString(Convert.FromBase64String(encoded)); Is this what

Re: [ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Ben Joyce
Adam, Christpher, and by no means least Barry... thank you very much. It was down to understanding the Assembly Name, Namespace and Class... which I had not got correct. it works now, and it seems relatively easy to implement a custom listener to log to SQL. Cheers all, Ben On 8/23/06, Barry K

Re: [ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Barry Kelly
Barry Kelly <[EMAIL PROTECTED]> wrote: > if the type is declared in the executable, or something like: > > type="MyAssembly,My.Namespace.Etc.CustomListener" Whups - the other way around, rather: type="My.Namespace.Etc.CustomListener, MyAssembly" ... etc. -- Barry -- http://barrkel.blog

Re: [ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Barry Kelly
Ben Joyce <[EMAIL PROTECTED]> wrote: > I'm trying to write a TraceListener to log Debug.Write output into a database. I've never had the need to write a trace listener, but I can tell you the reason for your error. > Public Class CustomListener This class is compiled into an assembly. >

Re: [ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Christopher Frazier
Try replacing System.Diagnostics.TraceListener in the type attribute with your namespace. -- -Christopher ASP.NET MVP | AspInsider http://chrisfrazier.net/blog -Original Message- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Ben Joyce Sent: Wednesday, A

Re: [ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Adam Sills
Your Type string is likely invalid. It's format is: "Type Name, Assembly Name" Assembly name format is: "Assembly Name[, PublicKeyToken][,Culture][,Version][,et cetera]" So unless your Type is called System.Diagnostics.TraceListener, you've specified the wrong type name. Adam.. -Original

[ADVANCED-DOTNET] Creating a custom TraceListener...

2006-08-23 Thread Ben Joyce
Hi all. I'm trying to write a TraceListener to log Debug.Write output into a database. I've made a simple class as follows: - 8<- Public Class CustomListener Inherits System.Diagnostics.TraceListener Public Overloads Overrides Sub Write(ByVal Message As String) 'yadda End Sub Publi

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Bob Provencher
>>A guid is always 16 bytes. So you could grab the 16 bytes and encrypt those. I think what you're working with is an ASCII representation of those bytes, in HEX. When databases don't support a varbinary type of guid type to store the 16 bytes in, you're doomed to use the ascii repr

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Barry Kelly
"Hevel, Shawn" <[EMAIL PROTECTED]> wrote: > I've got a Guid 36 positions long. I need a way to encrypt this and decript > this value. When I encrypt the value the length can be no longer than 30 > positions. Is there a way to encrypt the Guid into a length of 30 and > decript is back to a lengt

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Efran Cobisi
Well.. Each couple of characters in a guid is the hex encoded representation of a byte. Depending on the chosen encoding for the target, you should be able to convert each n bits of the original stream (which should be 32 characters and NOT 36, giving a total of 32/2*8=128 bits) into a somewhat co

Re: [ADVANCED-DOTNET] Guid question

2006-08-23 Thread Frans Bouma
> I've got a Guid 36 positions long. I need a way to encrypt > this and decript this value. When I encrypt the value the > length can be no longer than 30 positions. Is there a way to > encrypt the Guid into a length of 30 and decript is back to a > length of 36, without losing the original valu

[ADVANCED-DOTNET] Guid question

2006-08-23 Thread Hevel, Shawn
I've got a Guid 36 positions long. I need a way to encrypt this and decript this value. When I encrypt the value the length can be no longer than 30 positions. Is there a way to encrypt the Guid into a length of 30 and decript is back to a length of 36, without losing the original value of the G