Geeks With Blogs
Tex-blog Mobile and other stuff 70-536 preparation My experiences gained during MCTS 70-536 exam preparation
Exposing .NET Component to COM (Ch13)
Short sample for chapter 13, lesson 2. It shows how to write C# class library and export it to COM dll, which later is used by C++ test project. All is compiled from command line, so use Visual Studio 2005 Command Prompt. // This is the contents of LibClass1.cs, a library we want to expose to COM using System; namespace ClassLibrary { public interface ITestClass { void TestCallMe(); } public class TestClass : ITestClass { public void TestCallMe() { Console.WriteLine("I was called!"); } } } // This ......

Posted On Thursday, October 18, 2007 7:20 PM

SSLChat: simple presentation of .NET 2.0 SslStream class usage (Ch12)
Below you will find a sample solution for Practice 1 task in first objective of Chapter 12 review. This code is based on SslStream sample code that can be found in this class documentation. //#define USE_FILE_BASED_CERTIFICATE using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; using System.Security.Cryptograph... using System.Net.Security; using System.Security.Authenticat... using System.IO; using System.Threading; /* * ......

Posted On Monday, October 1, 2007 5:25 PM

Simple MD5 command line check utility (Ch12)
Cryptography namespace is really very powerfull, as a test application I wrote a simple MD5 check utility that computes md5 checksum for file and compares it with md5 file that was provided with downloaded file. Because most of the files that are being checked are quite huge - I added simple user feedback as a dots showing in console. using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Security.Cryptography; using System.Threading; using System.Text.RegularExpressi... ......

Posted On Sunday, September 23, 2007 5:06 PM

.NET Symmetric encryption sample wrapper (Ch12)
Below is a sample class showing how to encrypt and decrypt text when we have only password. It uses symmetric key algorithm. using System; using System.Collections.Generic; using System.Text; using System.Security.Cryptography; using System.IO; namespace EncryptionTester { class RijndaelWrapper { // Retruns salt from password. private static byte[] Password2Salt(String password) { int saltLength = password.Length * ((int)password[0] % 3 + 2); saltLength = Math.Max(8, saltLength); byte[] resSalt = ......

Posted On Saturday, September 22, 2007 4:12 PM

Language independent user account naming (Ch12)
Charter 12 lesson 2 gives in its Lab a sample code that will not work on everyones computer. The problem is with the Guest account name that is in English, which will not work on systems in different languages, like mine for example. Below code: DirectorySecurity ds = new DirectorySecurity(); string gname = "Guest"; ds.AddAccessRule(new FileSystemAccessRule(gname, FileSystemRights.Read, AccessControlType.Allow)); // Exception! Directory.CreateDirectory(@... ds); File.Create(@"C:\Guest\Data... ......

Posted On Tuesday, September 11, 2007 6:02 PM

Troubles with PrincipalPermission
While reading on Users Authentication and Authorization, I wrote a simple test code sample that didn't work at first as I would suppose it should. The code looks as follows: using System; using System.Security; using System.Security.Permissions; using System.Security.Principal; // ... public static void TestPrincipal(string role) { System.AppDomain.CurrentDom... PrincipalPolicy.WindowsPrin... try { PrincipalPermission sp = new PrincipalPermission(null, role, true); sp.Demand(); ......

Posted On Tuesday, September 4, 2007 3:28 AM

Writing simple custom formatter - implementation of IFormatter intereface
While writing practice programs for my 70-536 exam I encountered interesting problem of writing custom IFormatter implementation. .NET offers many classes that can fit most of ours serialization tasks, yet sometimes it might happen that we would like to do something differently. As I was looking for sample implementation of this interface, I noticed that there was very little about it in internet. One of the most interesting articles was "Run-time Serialization" by Jeffrey Richter found in april ......

Posted On Monday, July 16, 2007 3:32 AM

File access
I was recently writing a small practice application for learning pursposes. The task was to read windows log file: %windir%/WindowsUpdate.log and find "exit code" numbers. The problem I encountered was to actually open properly file. I was receiving exception: System.IO.Exception with message: "Additional information: The process cannot access the file 'C:\WINDOWS\WindowsUpdate.log' because it is being used by another process." my code looked something like that: string windir = System.Environment.GetEnvir... ......

Posted On Friday, June 29, 2007 5:26 PM

Copyright © Martinez | Powered by: GeeksWithBlogs.net