Experience in C++, C#, Java and Process : Living in Montreal

* What is my technical experience as a software developer

* What I have learned in the software business

* Where I am heading to in my career

* How to process in a project

Monday, January 31, 2005

Could not access 'CDO.Message' object while using SMTP in System.Web.Mail

Could not access 'CDO.Message' object:

1. The SMTP server must accept your outcoming email address
2. The SMTP server uses the standard port 25 for SMTP

MailMessage Message = new MailMessage();

Message.To = "joe@xxx.com";
Message.From = "xxx@sympatico.ca"; // This address must have been registered in the SMTP server you are using in SmtpMail.SmtpServer
Message.Subject = "Test";
Message.Body = "It is a testing message";

SmtpMail.SmtpServer = "smtp8.sympatico.ca"; // The SMTP server


Thursday, January 27, 2005

Reference places

Wednesday, January 26, 2005

Regular expression in C#

It is time consuming to build a regular expression.
I have a text file as below:

000010034981Mr. Ray BabsMontreal Canada Test@glinknet.com5142842903PassWord

How do I parse it? Note it is possible no value for address, email, fax, or password

Here is the regular expression I built ( 2 hours work)


It retrives the value to groups defined by "?"
(? ()(.[^]+))

Can you find better expression?
Regex regx = new Regex( @"(?\d+)\(?(.[^]+))\(?
()(.[^]+))\(?(.[^]+)())\(?()(.[^]+))\(?(.+()))", RegexOptions.IgnoreCase RegexOptions.Singleline RegexOptions.IgnorePatternWhitespace RegexOptions.Compiled );
Match m = regx.Match( line);
if ( !m.Success)
System.Diagnostics.Debug.WriteLine( line, "Import Text Error");
string id = m.Result( "${id}");
string name = m.Result( "${name}");
string address = m.Result( "${address}");
string email = m.Result( "${email}");
string fax = m.Result( "${fax}");
string pdfcode = m.Result( "${pdfcode}");

Tuesday, January 25, 2005

Data access in VS.NET demo : C#

1. http://www.dotnetjunkies.com/Tutorial/92FD33CA-7528-42A0-B974-8607A04B8B56.dcik
2. Introduction
When using the Visual Studio.NET IDE to create connections to MS Access databases, the default wrapper only puts Dates into Date/Time fields. This causes only the date to be saved and on the time when a date/time is written to the data set and Update is called.
How to fix it?
1) This is caused by the Wizard using DBDate rather than DBTimeStamp in the OleDbParameter method generated by the wizard. Ofcourse each time you regenerate this code using the wizard you will have to do the replace again.
Note: This has to be done in all OleDbParameter calls that use System.Data.OleDb.OleDbType.DBDate and replace with System.Data.OleDb.OleDbType.DBTimeStamp

Actually, this solution does not work. INSERT causes an error about type mismatch
2) Just change to System.Data.OleDb.OleDbType.Date and it will work.

3. Don't use 'Level' as a row name in a table, VS.NET IDE will not generate data adapter for it.

4. Expend the width of a column
int nWidth = objColumnStylegrdLogTableEvent_Level.Width+objColumnStylegrdLogTableInfo.Width + objColumnStylegrdLogTableTime.Width;
objColumnStylegrdLogTableInfo.Width = grdLogTable.Width - nWidth;

Get the application start up path : C#

// Gets the path for the executable file that started the application, including the executable name.
string aPath1 = System.Windows.Forms.Application.ExecutablePath;

// Gets the path for the executable file that started the application, not including the executable name.
string aPath2 = System.Windows.Forms.Application.StartupPath;

Sunday, January 23, 2005

.NET Framework Launch Condition

See Also
Launch Condition Management in Deployment SupportedRuntimes Property Message Property InstallUrl Property Working With Multiple Versions of the .NET Framework Side-by-Side Execution Properties for the Launch Conditions Editor
The .NET Framework launch condition is used to check for the common language runtime on a target computer during installation. This launch condition is automatically added to a deployment project when a dependency on the .NET Framework is detected; it cannot be removed.
If a version of the runtime specified in the SupportedRuntimes property is not found, the installation is halted. The user is presented with a Yes / No dialog box containing the text specified in the Message property. If the user chooses Yes, he is redirected to the location specified in the InstallUrl property (the default is a Microsoft Support Web site that contains a downloadable copy of the .NET Framework redistributable file).
In many cases, you will want to modify the InstallUrl property to point to your own location for the redistributable file. For example, if you are distributing your application on CD-ROM, you should include the redistributable file on the CD and change the InstallUrl property to a relative file path. If you change the InstallUrl property, you should also change the Message property to explain what is being installed and from where.
In addition, any Visual Studio .NET application or component that includes data access has a dependency on Microsoft Data Access Components (MDAC) version 2.7 or later. You will also need to add a launch condition to check for MDAC if your application includes data access. For more information, see Adding a Launch Condition for Microsoft Data Access Components.

Add a taskbar tray in C#

C# provides the NotifyIcon in task bar as a component. Here is some event it has to handle:

private void FormMain_Resize(object sender, System.EventArgs e)
if (FormWindowState.Minimized == WindowState) Hide();
private void notifyIconTask_DoubleClick(object sender, System.EventArgs e)
WindowState = FormWindowState.Normal;

Wednesday, January 19, 2005

Thread pool in C#

There is pre-created threads pool in C#. Use this threads in the pool could make the programming easier and faster. But be noted, if all of the threads in the pool are used, you will get an exception.
How does it exactly work for a threads pool? Can a application creates its own threads pool with the same design?

Need to be clarified!

Tuesday, January 18, 2005

Broken Software Design theory

It must exists a research area to break software design.
A software is designed for purpose and it must run correctly following the procedure designed. In the design process, the designer may only think of how to make it works smoothly which assumes every condition is followed correctly. It is not designed for exceptions which may make the software failed.

The Broken Software Design theory stduies how to break a software in the design stage.

It helps the designer to look at the design from different perspectives and improve the design as well.

For more information, please keep trace this blog.

Tuesday, January 11, 2005

XP can't boot to safemode !!!

Big problem:
1. I am working on a project and I installed a MIDI input device simulation driver called MIDI-YOKE.
2. After computer restarted as required, it stopped just before the login screen showup
3. I can not boot into safemode; I believe that the problems was in the YOKE driver.
4. What I am going to do? reformatting the disk and install XP again? No way! I have a lot of work to do: a new system release is coming and my computer can's stop
5. Clam down, Joe.
6. Search online, didn't find something really helpful.
7. I am a Microsoft believer. There must a way to let windows booting procedure ingore the YOKE driver
8. I tried to boot into Safemode command
9. OK, I can type dos command
10. Regedit, search the drive name, delete everything related to it.
11. Control.exe. Cool! the control panel shows up. Goto System->Device Management, find the YOKE device, delete it!
12. Reboot, then it is working!
13. I have to Ghost my disk C and back up all of my work.
14. Never try anything stupid

Saturday, January 08, 2005

C# : Marshal class is a bridge between managed memory and unmanaged memory

Marshal provides a collection of methods:
- allocating unmanaged memory,
- copying unmanaged memory blocks,
- converting managed to unmanaged types,
- interacting with unmanaged code.