Wanta .NET ?

Dave Wanta
Registry Hacks

I just rebuilt my laptop last night, and after 10hrs of installs, I’m finally back to a ‘usable’ state.  One of the things I had forgotten about, that I take for granted was all of the registry hacks that I was used too. Basically, these hacks were ones I made so that additional options would show up when I either right-clicked on a folder or a file, in explorer.

DISCLAIMER
DANGER WILL ROBINSON! DANGER!!!

Modify your registry at your own risk. If you hose your computer, I am not responsible.

Ok, so here are some of the keys I just added, and a brief explanation of what they do. They point to additional tools and utilities, so you may need to modify the paths to fit your system. I’ll list all of the keys at the end, so you can create a .reg file, and import them.

1.)This key allows you to right-click on a COM dll, and register it, just like you ran regsvr32 against it, from a command prompt.

[HKEY_CLASSES_ROOT\dllfile\shell\Register\command]
@="regsvr32 /s %1"

2) Same as above, except un-registers the dll.
[HKEY_CLASSES_ROOT\dllfile\shell\Unregister\command]
@="regsvr32 /u /s %1"

3)Register a COM .exe
[HKEY_CLASSES_ROOT\exefile\shell\Register\command]
@="regsvr32 /s %1"

4)Un-Register a COM .exe
 [HKEY_CLASSES_ROOT\exefile\shell\Unregister\command]
@="regsvr32 /u /s %1"

5)Right-click on a .NET assembly, and install in the GAC
[HKEY_CLASSES_ROOT\dllfile\shell\Register In GAC\command]
@="C:\\Program Files\\Microsoft.NET\\FrameworkSDK\\Bin\\gacutil /i %1"

6)And most importantly, right-click on a folder, and open it’s path in a  command prompt.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\CMD Here\command]
@="cmd.exe /k pushd %L "


Here are all of the keys at once. Do you have any cool hacks! Add them below in the Comments section.
Cheers!
Dave


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\dllfile\shell\Register\command]
@="regsvr32 /s %1"

[HKEY_CLASSES_ROOT\dllfile\shell\Unregister\command]
@="regsvr32 /u /s %1"

[HKEY_CLASSES_ROOT\exefile\shell\Register\command]
@="regsvr32 /s %1"

[HKEY_CLASSES_ROOT\exefile\shell\Unregister\command]
@="regsvr32 /u /s %1"
 
[HKEY_CLASSES_ROOT\dllfile\shell\Register In GAC\command]
@="C:\\Program Files\\Microsoft.NET\\FrameworkSDK\\Bin\\gacutil /i %1"


[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\CMD Here\command]
@="cmd.exe /k pushd %L "

 

New OBJECTDATA virus

From the IMAIL list I'm on. Thought I would spread the love.

During the past few weeks, virus writers have come up with at least 6 new
tricks to get their viruses past mailserver virus scanners.  They started
by spreading in .ZIP files, then moved to static encrypted .ZIP files, then
moved to dynamic encrypted .ZIP files, then started using pictures to give
out the passwords, then started using encrypted .RAR files.  The latest
trick, first announced this morning, is that they are now using the OBJECT
DATA exploit.  With this, the virus isn't spread in the E-mail, so it can't
be detected.  Worse, a user doesn't have to open an attachment for it to
spread.

There is now a new interim release of Declude Virus that will automatically
detect the OBJECT DATA exploit, which is the only way for a mailserver
virus scanner to prevent Bagle.Q or Bagle.R from spreading.  For people
using Declude Virus, we recommend upgrading to the latest interim release
(at
http://www.declude.com/interim ).  Please note that you MUST have an
up-to-date Service Agreement to download this release.  If you do not have
an up-to-date Service Agreement, you can order it online at
http://www.declude.com/order.htm , and then you can immediately download
the latest interim release.

If you are using another brand of virus scanner, you should upgrade as soon
as the vendor has an upgrade available to detect the OBJECT DATA exploit.

                                                   

Patch, Patch, Patch.

Cheers!
Dave

Postmaster, why isn't my email being delivered?!?

This is classic!

Some of my products integrate with IMAIL, and I'm on an IMAIL technical listserver. This post just came across, it had me in stiches.

<quote>
Our town USPS postmaster called in and asked one of the tech guys this:

He wants us to change the heading on our undeliverable emails from
"Postmaster" to something else.......because he is getting phone calls
at the post office from people questioning why their email is not going
through.

I kid you not......

Now, after you quit laughing is this even possible?

</quote>

What a riot!

Using the Flags Attribute

Using the Flags attribute

The other day I had to implement a method that works the same way as the Regex ctor (allow multiple options to be set). Basically, I needed to have an enumeration that used the Flags attribute. Since I had never done this before, it was rather interesting. The 1.0 Framework help docs are pretty sparse (which is what I had to use) on this topic, so I thought I would write about my implementation here.

I have a method I was exposing called:


public void ExecuteColor( ColorOptions options ){
   //in here I had to check to see which color was selected.
   //I also wanted to provide the method caller with the option of specifying many colors, or no colors,
  // but did not want to use the params keyword. 
}

Creating the Enum
This can be accomplished by creating an enum with the Flags attribute.
It looks like:

 [Flags]
 public enum ColorOptions
 {
    None =0,
    Red = 1,
    Blue = 2,
    White = 4,
    Black = 8,
    Green = 16
 }

By using the Flags attribute, you can perform bitwise manipulation on the enumeration, to check and see which color options where set.

To do this, I used a helper function called:

  public static bool IsColored( ColorOptions color, ColorOptions myColor  )
  {
       if( ( myColor & color ) != ColorTypes.None )
          return true; //if the color was selected, return true
       else
          return false; //if the color wasn’t selected, return false
 
}

Putting it all together
So, now my ExecuteColor() method looks like 

public static void ExecuteColor( ColorOptions options )
  {
   //For demo, check to see if each color was called, and write out True or False
   string line = "The color {0} was set: {1}";
   Console.WriteLine( string.Format( line, ColorOptions.Red, IsColored( ColorOptions.Red, options ) ) ); //Red
   Console.WriteLine( string.Format( line, ColorOptions.Blue, IsColored( ColorOptions.Blue, options ) ) ); //Blue
   Console.WriteLine( string.Format( line, ColorOptions.White, IsColored( ColorOptions.White, options ) ) ); //White
   Console.WriteLine( string.Format( line, ColorOptions.Black, IsColored( ColorOptions.Black, options ) ) ); //Black
   Console.WriteLine( string.Format( line, ColorOptions.Green, IsColored( ColorOptions.Green, options ) ) ); //Green
  
}

And this allows developers to call ExecuteColor() by setting 1 color, multiple colors, or no colors. Here are some example method calls

   ExecuteColor( ColorOptions.Red );  //Set only Red
   ExecuteColor( ColorOptions.Red | ColorOptions.White ); //set Red and White
   ExecuteColor( ColorOptions.None ); //don't set any colors
   ExecuteColor( ColorOptions.Green | ColorOptions.Black | ColorOptions.Blue ); //Set Green, Black, Blue

Cheers!
Dave


 

System.Web.Mail Explained - Part 3

Wow, I can’t belive how long its been since I’ve last blogged. Time has just flown by.

Well, I’ve been putting off Part 3, which deals with specifically working with System.Web.Mail, but I finally got around to it. Every time I started on this part, I kept saying this is way too large, and felt it needed its own website, in the form of a FAQ. So I built one. You can see it here: System.Web.Mail, OH MY! at http://www.SystemWebMail.com If I’ve missed anything, feel free to let me know.

Just as an outline, here are some of the FAQs I cover.

Cheers!
Dave

Demeanor Just Rocks

I just have to blog about the AWESOME obfuscator Demeanor. I ran into a problem today while testing an upcoming version of aspNetEmail.  It seemed that when I obfuscated aspNetEmail with Demeanor, the obfuscated version was throwing an exception that the non-obfuscated version wasn’t. So I quickly fired off an email to Brent at Wiseowl explaining my dilemma. Within 10 minutes I had an updated version of Demeanor in my inbox and I was back in business!!!. Not only did he provide me with a solution, he gave me some additional tips and tricks for better obfuscation. He just ROCKS when it comes to customer service. 

Cheers!
Dave

123aspx.com has RSS

Well, I finally exposed the latest resources on www.123aspx.com as a RSS feed. If you want to stay up-to-date with all the latest and greatest articles, tutorials, and products, you can subscribe to the feed here.

Cheers!
Dave

kbAlertz has RSS Feeds -- Finally!

If you haven’t heard of kbAlertz, it’s a website I setup to email me (and other subscribers) when Microsoft publishes new KB articles for their technologies.

I’ve finally gotten around to exposing the Kbs as a RSS feed. Basically, pick the technology you want to subscribe to, and I’ll expose the latest 10 Microsoft Knowledge base articles as a RSS feed.

You can pick from the list of technologies here.

This is my first attempt at RSS feeds, so if I’ve buggered something up, let me know.

Cheers!
Dave

System.Web.Mail Explained - Part 2

Introduction
Ok,  in my last blog entry you’ve seen how SMTP works. This article will delve into System.Web.Mail to see how it was built.

I’m sure when Microsoft was building the CLR framework they had many thousands of priorities on what to build first, and how to build it. Many of the namespaces and classes in the CLR framework are simply wrappers around some of the legacy COM components. System.Web.Mail is one of those namespaces.

CDOSYS and CDONTS
System.Web.Mail is unique when it is a wrapper round the COM components, because it is actually a wrapper around two COM components, CDOSYS and CDONTS. Internally, System.Web.Mail will check what the operating system it is being executed on, and then all the respective COM component. This makes troubleshooting interesting, because moving System.Web.Mail code from OS to OS can cause different exceptions to occur.

Using Anakrino, let’s look internally at what System.Web.Mail is doing.
In this first screen shot, I’ve expanded the System.Web.Mail.SmtpMail class to see some internal classes called CdoNtsHelper and CdoSysHelper.




These classes merely wrap CDONTS.NewMail and CDO.Message respectively. In fact, here is what their cctor()'s code looks like

[ CdoNtsHelper ]
private static CdoNtsHelper() {
 CdoNtsHelper._helper = new LateBoundAccessHelper("CDONTS.NewMail");
}

[ CdoSysHelper ]
private static CdoSysHelper() {
 CdoSysHelper._helper = new LateBoundAccessHelper("CDO.Message");
}

Ok, so now that we see System.Web.Mail is a COM wrapper, lets look at how System.Web.Mail.SmtpServer.Send() determines what class to call. Internally, the Send() method looks like

[ SmtpServer.Send() ]
public static void Send(MailMessage message) {
 if (Environment.OSVersion.Platform != 2)
  throw new PlatformNotSupportedException(SR.GetString("RequiresNT"));
 if (Environment.OSVersion.Version.Major <= 4) {
  CdoNtsHelper.Send(message);
  return;
 }
 CdoSysHelper.Send(message);
}

From this code we can see that System.Web.Mail requires NT. It also checks to see if NT is version 4.0 or less. If so, it will use the CDONTS.NewMail object. If the OS is greater than 4.0, it uses the  CDO.Message object. 

So now that we know how System.Web.Mail was built, it makes troubleshooting ‘easier’. We also begin to realize some of the limitations of System.Web.Mail, and realize that it can’t outgrow the limitation of the CDONTS.NewMail or CDO.Message object.

What's Next?
In the next blog entry, I hope to discuss some of common exceptions thrown by System.Web.Mail and how we can troubleshoot them.

Questions? Comments? What do you think?

 

System.Web.Mail Explained

System.Web.Mail and SMTP Explained

Building aspNetEmail, aspNetMime, and aspNetMX, has caused me to debug quite a few different email scenarios, for both client and friends.  Over the next few blog entries, I’m going to explore SMTP and System.Web.Mail to explain what is happening.

Lets first start with SMTP. SMTP (Simple Mail Transfer Protocol ) was first introduced around 1982 with RFC 821. Its now been updated to RFC 2821. SMTP is *ONLY* used for sending email. It is not used for retrieving email from the server, or managing email, or parsing it. Its only used for client to server, or server to server communication.  SMTP is totally text based. Which means, if we want to troubleshoot a SMTP session, its as easy as opening a Telnet session to a mail server and issuing commands.

SMTP Commands
Speaking of commands, lets talk about a couple of them. HELO, MAIL FROM, RCPT TO, DATA, RSET, QUIT. These commands are issued during a SMTP Session. The also need to be issued in a certain order.

Each of these commands take a line of text (with the exception of DATA), and are executed with a Carriage Return Line Feed Combination.

DATA is actually executed with a Carriage Return Line Feed . Carriage Return Line Feed combination
[VB]
vbCrLf + "." + vbCrLf
[C#]
"\r\n.\r\n"

After each of these commands are executed, the server will reply with a 3 digit reply, followed by a textual description. From server to server, this description may be different, but the command has to be the same. For a detailed look at the possible replies, check out RFC 2821.

HELO, MAIL FROM, RCPT TO, RSET, QUIT Commands

HELO
HELO is merely used to say "hello" to the server and introduce yourself. And example of the command is
HELO davesLaptop

Here I basically told the mailserver who I was.

MAIL FROM
The next command, in the SMTP session is the MAIL FROM command. This command will tell the server who the mail is from. Its issued like
MAIL FROM: <
dave@aspNetEmail.com>

RCPT TO
The next command, is the RCPT TO command. It tells who the mail will be going too. For example:
RCPT TO: <
you@yourcompany.com>
RCPT TO: <
him@hiscompany.com>
RCPT TO: <
her@hercompany.com>

As you can see, there were multiple RCPT TO commands issued here.  A RCPT TO command must be issued for everyone listed on your ‘TO’, ‘CC’ and ‘BCC’ line of the email.

DATA
The next command issued is DATA, which will actually send the text content of the email. The text content includes all of the email headers and the body.  Because the content contains multiple lines, the DATA command is terminated with a CrLf.CrLf sequence. For example:

DATA
This is my text email. It will
contain
a
few
lines of data


.

(notice the period at the end, on a line by itself? That’s how the DATA command was terminted).

RSET and QUIT
The last two commands that can be issued anytime during the SMTP session are the RSET and QUIT commands. They are executed on a line by themselves. RSET resets the SMTP session back to its original state, and clears any previously issued commands. QUIT gracefully closes the SMTP session.

To see this in action, here is a screen shot of a telnet session between me and my SMTP server.

 

Conclusion
In this blog entry, I’ve explained some of the SMTP commands used during a SMTP session. In the next blog entry, I’ll delve more into the System.Web.Mail namespace.


 

More Posts Next page »