|
I like "C# Essentials" by O'Reilly press, "Developing Applications with Visual Studio .NET" by Grimes, and Gunnerson's C# book to some extent.
For Windows Forms I like ".NET Windows Forms in a Nutshell" from O'Reilly, and Petzold's "Programming Windows with C#". Windows Forms is so vast that while both of these books are big, neither comes close to covering the whole thing.
I did not like Archer's book at all.
|
|
|
|
|
A s h wrote:
I did not like Archer's book at all.
Blasphemy!!!
Just kidding , different people have different styles of learning. Tom's style of teaching may not be the best for everybody. I recommend going to your local Borders or Barnes & Noble and skimming the book to see if it's right for you.
Hawaian shirts and shorts work too in Summer.
People assume you're either a complete nut (in which case not a worthy target) or so damn good you don't need to worry about camouflage...
-Anna-Jayne Metcalfe on Paintballing
|
|
|
|
|
whatever you do, avoid Windows Forms Programming with C# by Erik Brown
Its one of those books where every example builds on the previous example's code. Horrible, horrible idea. It's like the opposite of the perl cookbook.
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Hi all!
I am trying to encrypt data with C# and decrypt the same data using VC++ 6, both using a password. I believe that I am very close on this one but am currently stuck and am receiving error 2148073477 on the VC++ CryptDecrypt() call. My keys generated by C# and VC++ are the same, so that seems to be okay.
My C# code is as follows:
// C# Begin *********************************
string s = "Hello";
RC2CryptoServiceProvider sp;
MemoryStream ms;
byte[] toEncrypt;
byte[] fromEncrypt;
byte[] IV = new byte[8];
byte[] key;
sp = new RC2CryptoServiceProvider();
sp.Mode = CipherMode.CBC;
sp.KeySize = 40;
sp.EffectiveKeySize = 40;
ms = new MemoryStream();
// Create the key
PasswordDeriveBytes pdb = new PasswordDeriveBytes( "ABCD-1234-XXXX-0000", IV );
key = pdb.CryptDeriveKey( "RC2", "MD5", 40, IV );
sp.Key = key;
// Create the crypto stream
CryptoStream cs = new CryptoStream( ms, sp.CreateEncryptor(), CryptoStreamMode.Write );
// Encrypt the data
toEncrypt = Encoding.UTF8.GetBytes( s );
cs.Write( toEncrypt, 0, toEncrypt.Length );
cs.FlushFinalBlock();
ms.Position = 0;
fromEncrypt = new byte[ms.Length];
ms.Read( fromEncrypt, 0, (int)ms.Length );
// Cleanup
cs.Close();
ms.Close();
// C# End *********************************
My VC is as follows:
The VC code contains a byte array that I populate after running the C# code and stepping through.
It contains a call to CryptEncrypt() and CryptDecrypt() to prove that encryption is working with the generated key.
I also exported the key to ensure that it was identical to the C# key.
// VC Begin *********************************
HCRYPTPROV hCryptProv;
HCRYPTKEY hKey;
HCRYPTHASH hHash;
CHAR szPassword[] = "ABCD-1234-XXXX-0000";
CHAR szMessage[512] = "";
DWORD dwLength;
BOOL b;
BYTE* pbKeyBlob;
BYTE bTest[] = {0x1e, 0x03, 0x91, 0xbe, 0xef, 0x2b, 0xdf, 0x91};
strcpy( szMessage, "Hello" );
b = CryptAcquireContext( &hCryptProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, 0);
b = CryptCreateHash( hCryptProv, CALG_MD5, 0, 0, &hHash);
dwLength = strlen( szPassword );
b = CryptHashData( hHash, (BYTE*)szPassword, dwLength, 0);
b = CryptDeriveKey( hCryptProv, CALG_RC2, hHash, CRYPT_EXPORTABLE, &hKey);
dwLength = strlen( szMessage );
b = CryptEncrypt( hKey, 0, TRUE, 0, (BYTE*)szMessage, &dwLength, 512 );
b = CryptDecrypt( hKey, 0, TRUE, 0, (BYTE*)szMessage, &dwLength );
// The call that FAILS!
dwLength = 8;
b = CryptDecrypt( hKey, 0, TRUE, 0, bTest, &dwLength );
DWORD dw = GetLastError();
b = CryptExportKey( hKey, NULL, PLAINTEXTKEYBLOB, 0, NULL, &dwLength);
pbKeyBlob = (BYTE*)malloc(dwLength);
b = CryptExportKey( hKey, NULL, PLAINTEXTKEYBLOB, 0, pbKeyBlob, &dwLength);
free( pbKeyBlob );
b = CryptDestroyHash( hHash );
b = CryptDestroyKey( hKey );
b = CryptReleaseContext( hCryptProv, 0 );
// VC End *********************************
Is there something I'm missing?
Thanks
Cory Baker
|
|
|
|
|
I have an application that uses a simple Webservice on my locaolhost, I have moved the webservice to the production
server and I have re-reference my application to the new server
location. I may need to move this webservice soon and would like to know if I can code the application so I can change
the server my webservice is located without having to rebuild the application.
Thanks for your help
=================================
When I was in school, all I wanted was to get out into the real world.
Now that I'm in the real world, all I want is to go back to school.
|
|
|
|
|
Hi there,
I had some questions. I was learning c# and i saw this code:
static int amountopen = (0 - 500);
Hmm.. wonder, does it means we are setting a scope from 0 to 500 for integer amountopen?
This is first time i seen.
Oh ya, another added question. How does virtual keyword comes in handy in c# programming? Any good samples and explanations on that please.
Thanks.
Regards,
Chua Wen Ching :p
|
|
|
|
|
chuawenching wrote:
static int amountopen = (0 - 500);
Hmm.. wonder, does it means we are setting a scope from 0 to 500 for integer amountopen?
Nope, it just means make amountopen = to the result of subtracting 500 from 0.
chuawenching wrote:
How does virtual keyword comes in handy in c# programming? Any good samples and explanations on that please.
Here's a link that should help: http://www.jaggersoft.com/csharp_course/16_Inheritance_files/frame.htm[^] Click on "virtual Methods".
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Thanks for the reply.
amountopen = to the result of subtracting 500 from 0.
--> subtract 500 from 0 means amountopen = -500 ???
So why can't the coder code this:
amountopen = -500
rather than
amountopen = (0-500)
What is his purpose? Thanks for the virtual link?
Is that the best site to learn oop way in c#? Must the slides does not show a complete source code. I want to learn while coding? Thanks.
Regards,
Chua Wen Ching :p
|
|
|
|
|
chuawenching wrote:
So why can't the coder code this:
amountopen = -500
rather than
amountopen = (0-500)
I don't know. If you can ask him/her, hopefully you can find out. There's no obvious answer, except perhaps the developer didn't know he/she could just write -500.
chuawenching wrote:
Is that the best site to learn oop way in c#? Must the slides does not show a complete source code. I want to learn while coding?
It's the best one I could come up with on short notice. I'm sure there are others out there that do a better job. Here's one from MSDN which may serve you better: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcoriCProgrammersReference.asp[^]. Depending on how much previous experience you have with other languages, a book on C# programming may also help.
Good luck!
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Thanks
But i feel that msdn tutorials a bit complicated. So many links here and there. And at the end i learn nothing.
Regards,
Chua Wen Ching :p
|
|
|
|
|
Hi,
a little question:
What is the default type access modifier for a class/struct?
The MCAD Study Guide I'm reading says public while a tutorial from MS'site (Dr. GUI) says internal?!?!
Oh what to believe? ;P;P
|
|
|
|
|
Internal, AFAIK.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
Java heathen.
The default access is 'private', of course.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Blake Coverett wrote:
Java heathen.
Yep.
Blake Coverett wrote:
The default access is 'private', of course.
I think he was referring to the default accessibility for a class inside a namespace, not for the members of a class themselves. And according to this[^], it's internal .
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
The question is a big vague, but upon rereading it I think you are right about what he was asking. And yes indeed, the default access of a class is protected. Touche'.
*grins broadly* On the other hand... there is no 'accessibility inside a namespace' at all in C#. That is an even more blantant Java-ism. Assemblies are a protection boundary, namespaces are have no impact on accessibility whatsoever.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Yeah I was reffering to access modifiers as applied to a class or struct, for example:
public class<br />
{<br />
}
By surfing MS's site I've come to the conclusion that it's internal which is what I've always thought it was until I read the MCAD Study Guide from MS where it is clearly stated as being public ! . How can something like that slip by the technical editor?!?!
|
|
|
|
|
Does anyone know how using the Drawing.Image.Bitmap class I can read a bitmap in CMYK format, modify it, and save it preserving the CMYK attributes. Currently it reads it in just fine but when writing it converts to RGB.
|
|
|
|
|
Sorry, that's not going to happen with the Bitmap class, at least not in this revision. If you are working with CMYK data you probably need more control over your color matching then GDI+ currently provides as well.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
I need to send an email containing a link ( HTML href tag ).
Currently i can succesfully send mails using these namespaces
System.Web.Mail;
System.ServiceProcess;
The message is sent using the SmtpMail.Send( msg );
I tried including a string containing a href tag in the message body but it didnt work. I also tried including a complete html document in the message body. It didn't work either.
Anyone got an idea on how to do this ?
|
|
|
|
|
Did you set the BodyFormat property of the message to MailFormat.Html?
---------------------
Marshall Rosenstein
.NET Consultant
|
|
|
|
|
No i didn't set that property...
I read your reply, tried it and it works fine !
Thanks a lot !
|
|
|
|
|
I have an application that has a form which is bound to a DataView contained within another object. The form allows be to navigate through the rows of the table in a similar way to the Binding class overview example in the MSDN documentation (i.e. I have two buttons which change the position Property of a BindingManager). Everything works fine until I try and insert a new row. The problem is that while the row inserts just fine, the DataBindingManager doesn't seem to know about it.
Example:
I have two records (1 and 2) and I add one more, the new record becomes record one (because they are sorted alphabetically) and the BindingManager position gets set to 2 (because I was looking at the old record one before). I can still navigate up to the next record (now record 3) and back to record 2 (previously 1), but I can't get to the new record at all. For some reason it won't let me set the Position property to 1!
Sorry if that's a little difficult to follow, but does anybody know what's going on here? I've tried creating a new BindingManger object, but that doesn't seem to work, I've tried recreating the DataView and that didn't help. I tried completely reloading the data from the database and that didn't work. Any ideas????
Thanks
|
|
|
|
|
I've finally hit upon the problem, so in case anybody else encounters this: The problem was that I hadn't bother to set all of the columns in my new row and some of the ones I hadn't set were supposed to be bound to controls. Because the BindingManager couldn't bind all the controls in decided to just ignore my request to go to the new record. I'm not sure if only happens with certain controls. I have textboxes, comboboxes, checkboxes and a datepicker on my form and I suspect it's probably just a subset of those that are causing the problem (probably the checkboxes and maybe the datepicker).
|
|
|
|
|
After a quick experiment I can confirm that it's both the checkboxes and the datepicker that cannot be left null. The textboxes and comboboxes don't care.
|
|
|
|
|
Hi,
I have form in which there is a panel. This Panel is filled with controls from a different .net dll .
I want to serialize this Panel only. If I serialize the whole class in the .net dll it gives me serialization errors for the other fields in the class like Form, Panel and XMLTextReader.
How can I serialize this Panel ?
Thanks,
Paul
|
|
|
|
|