Answers to Software Questions the Experts Would Not Answer. Microsoft.NET, Java, Spring, Hibernate, JavaScript, C#, SQL Server as well as Mac, Solaris, Linux, CISCO IOS and related now include some Automotive IT! You could be having the same problem for hours like me!
Monday, February 12, 2007
System.Net.Mail.SmtpClient How To Send User Name and Password?
On .NET 2.0 framework there is now a new namespace called System.Net.Mail, so we should all take advantage of it. So I started to work on it. One problem; most of SMTP servers we deal with require some type of credentials.
If you look at the MSDN docs for the SMTP class, the MSDN's description and example of how to do this is really poor in the document. I would say that 99% of the time, we just want to send a user name and password along with the SMTP traffic, and do not need to rely on default user credentials in the CredentialsCache. It took me a bit of efforts to find how to do this, but it is actually simple. Make sure to include the following namespaces first.
The following example also shows how I am using the Properties object to pull the Application configuration file information. Since SMTP config is something that needs change from time to time, it is best to store the information in a configuration file. The only sticky issue is of course, the password saved in plain text, but in my case it is a closed application so this isn't an issue for me, and even if that leaks, it is not an immediate threat.
using System.Net.Mail;
using System.Net;
using System.Security.Principal;
private void SendEmail(string subject, string body)
{
string smtpServer = Properties.Settings.Default.SMTPServerBlankIfDontWantEmail;
if ((smtpServer == null) (smtpServer == "")) return;
try
{
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress (Properties.Settings.Default.EmailTo));
msg.From =(new MailAddress(Properties.Settings.Default.EmailFrom));
msg.Body = body;
SmtpClient c = new SmtpClient(Properties.Settings.Default.SMTPServerBlankIfDontWantEmail,
Properties.Settings.Default.SMTPPort);
string token = "mmonitor";
c.Credentials = new NetworkCredential
(Properties.Settings.Default.SMTPUserName,
Properties.Settings.Default.SMTPPassword);
// c.SendAsync(msg, token); // Don't hang the rest of the stuff is SMTP hangs.
c.Send(msg);
this.toolStripStatusLabel2.Text = "Sent email";
}
catch (System.Exception ex)
{
this.toolStripStatusLabel2.Text = ex.Message;
}
}
Saturday, February 10, 2007
SQLExpress Logs Too Many "Starting up Database" Message
I researched this and the reason why the SQL Express does this is to conserve resource by making database "Auto Close" by default. In my case, I constantly use this database and also a remote application status display pulls the data to report the progress, it would not make much sense for the database to close so quickly.
The way to turn the message off is to disable "Auto Close"mode, and where you do that is in the Database's property (use SQL Server Management Express). You will find the Options node and the Auto Close is pretty much at the top of the list of options you can turn "false".
Thursday, February 08, 2007
Running SQL 2000-5 on A Domain Controller - No!
At any rate, this question comes up fairly often because of that: "Can you run a SQL Server 2005 on a Domain Controller". The Microsoft's answer is basically NO but do it at your own risk (link).
The issues stem from basically how the SQL Service starts up in what security role.
Some key points of the reasons why they are against are;
- You cannot promote (dcpromo) or demote the domain controller's role after SQL runs. This basically means that you need to set up the DC and its role first before slapping on the SQL.
- SQL service must run on a domain acount and not on a local machine's system account or Network account.
Monday, January 22, 2007
SQL Server 2005 Express Remote Connection Setup on Workgroup XP
- Firewall - To eliminate the possibility of a firewall getting in the way, first test everything without it. Then enable. GO to the bottom of this post and there will be additional info on how to make an exception to the firewall for SQL Express.
- If using SQL Authentication, this is not enabled. Download the SQL Server Management Express then right click on the server and enable Mixed mode authentication. Otherwise you get a "security error"
- It is best if the server is registered under DNS or ActiveDirectory, but if that is not the case then runt the SQL Server Configuration Manager and activate the SQL Server Browser. You need to Enable this service.
- KEY TO THE BIG BIG MISTERY: The default SQL Express installation REQUIRES that the SQLBROWSER be enabled on the Windows Firewall (not just allowing Port 1433 if you came from out-of-the-box isntall with SQL 2000). The standard location for this is at C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe Make sure to set an Application Exception in the Windows Firewall even if you are accessing it locally!
- Also while you are at it, make sure that TCP/IP protocols are all enabled as below.
This was taken from Microsoft Web Site http://download.microsoft.com/download/f/1/0/f10c4f60-630e-4153-bd53-c3010e4c513b/ReadmeSQLEXP2005.htm
To enable TCP/IP:From the Start menu, choose All Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Configuration Manager. Optionally, you can open Computer Manager by right-clicking My Computer and choosing Manage.
In Computer Management, expand Services and Applications, expand SQL Server Configuration Manager.Expand SQL Server 2005 Network Configuration, and then click Protocols for InstanceName.In the list of protocols, right-click the protocol you want to enable, and then click Enable.
The icon for the protocol will change to show that the protocol is enabled.To enable the firewall:Click Start, click Control Panel, and then click Network Connections.From the navigation bar on the left, click Change Windows Firewall settings.On the Exceptions tab, in the Programs and Services box, you will probably see that SQL Server is listed, but not selected as an exception. If you select the check box, Windows will open the 1433 port to let in TCP requests.
Alternatively, if you do not see SQL Server listed, do the following:Click Add Program.Click Browse.Navigate to drive:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BINNAdd the file sqlservr.exe to the list of exceptions.
If using SQL Authentication, this is not enabled. Download the SQL Server Management Express then right click on the server and enable Mixed mode authentication. Otherwise you get a "security error"
It is best if the server is registered under DNS or ActiveDirectory, but if that is not the case then runt the SQL Server Configuration Manager and activate the SQL Server Browser. You need to Enable this service.
Also while you are at it, make sure that TCP/IP protocols are all enabled.
Friday, January 19, 2007
WinOBJ - Lists Device Driver and OS Stuff
Wednesday, November 22, 2006
Why Email to AOLand Mac.COM (Same thing) Bounces - Finally Understood The Reason.
Today I got an email from our ISP explaining what is going on, and it finally made it very clear to me the source of the problem.
The source of the problem are occuring in two steps.
(1) Someone in the same email system on my ISP sets up a permanent forward from their own account to their own AOL account.
(2) The forwarded email contains some SPAMS.
(3) The user marks the SPAM on the AOL side. This causes the users' ISP as the spammer.
(4) This shuts down the ALL of the users on the ISP that is using the same SMTP server.
My ISP said that AOL is not going to fix this issue, and cannot ask users from stop forwarding to AOL voluntarily so they said they won't forward anything to AOL.
Now it makes sense.
Monday, November 13, 2006
SCSI - A Dying Interface?
Just take a notebook computer and try to find a way to connect it to a Ultra SCSI device you may have.
First you need to find a SCSI controller, presumably in PCMCIA or CardBUS format. Just about only people who still sell those are Adaptec, but if check the SCSI drivers, they basically stopped working on around 2000, and while their drivers would work on XP, there has not been any updates since.
Surely, there are USB and FireWire converters, but there always will be issues of driver compatibilities and your legacy app will also stop working.
And shortly you wont' be able to plug in a SCSI card to your notebooks because new notebooks will be equipped only with ExpressCARD architecture, which is based on PCI Express (not to be confused with PCI extended) architecture. At this time of writing there is no major manufacturer which makes ExpressCARD format SCSI adaptor.
Even in Enterprise class storage field, things are moving to iSCSI SANs for small SANs and the iSCSI RAID boxes themselves are based on SATA disks. I think SCSI will be around the paradigm shift has already occur ed in the industry at least in consumer and medium business market place, since I either cannot buy them or there are abundance of chaper alternatives already out.
Turn On/Off Services and Drivers on Windows XP
It is msconfig.exe Just run it from the Start menu.
Wednesday, October 25, 2006
Hex Dump of File For Windows (XD)
0: 4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00 | MZ.......... ..
10: B8 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 | ╕.......@.......
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 E0 00 00 00 | ............α...
40: 0E 1F BA 0E 00 B4 09 CD 21 B8 01 4C CD 21 54 68 | ..║..┤.═!╕.L═!Th
50: 69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F | is program canno
But, on Windows I had to some hunting around to find a program that did this. I actually wrote one a long time ago and posted on the web, but the ISP crashed one day, and lost the file forever.
So here it is, there is a freeware called XD from who else, John Walker (of the AutoCAD fame) who now lives in Switzerland and runs The Fourmilab. http://www.fourmilab.ch/xd/
I suggest that you just take xd.exe and then drop that into Windows/System32 directory. This way you can call this handy utiliy anywhere (since there is a default path to that directory).
While you are at it, you should try Home Planet. It is really fantastic and free Home Planetarium software that runs on you Windows. Complete with Cookoo clock (since he lives in Switzerland). There are many other stuff there.
Windows XP - How to Set IP Address From Script
netsh interface ip set address name="Local Area Connection" static 192.168.0.68 255.255.255.0 192.168.0.1 1
What they mean:
- netsh is the command already built into your XP
- interface ip set address is the command to set a fixed IP.
- name="Local Area Connection" is the name of the interface. This is the name of the interface that you can see on your Networks window from the Control Panel.
- static means it is a static IP
- 192.168.0.68 is an example IP address that I want to assign
- 255.255.255.0 is the netmask as an example
- 192.168.0.1 is the gateway as an example
- 1 is the routing metric, you can almost always leave this as 1
Tuesday, October 17, 2006
Visual Studio 2005 C++ Lacking Namespace Issue
When compiling very simple code including a template
#include
... some code...
list
I have started to get a compliler error "error C2143: syntax error : missing ';' before '<'"
Then I started to remember;
You do need to include;
using namespace std;
I am hereby reminding myself to do this.
Tuesday, October 03, 2006
Mac OS X with Windows NTFS USB2/Firewire Drive READ ONLY
http://docs.info.apple.com/article.html?artnum=75320
On a related scheme of things, the Mac OS X "Connect To Server" in the Finder allows you to connect to an FTP server to get the file, but
again, it does not allow you to write to the FTP server (this is not a feature in the Windows IE nor Expolrer either), but it is something you should be aware of. If you need to write file via FTP on your Mac OS X system, you'd be best off with Fetch software. I like it because it support the Automator.Update on this issue: 17 October 2006
I have tried a bit more at it. I thought that we could convert the format from NTSF to FAT32 non-destructively. Apparently this is not easy to do without buying some commercial tool.
There is something called NTSF for Mac on Source Forge http://sourceforge.net/projects/ntfsosx/ But I have not given it a shot yet. The Forum there says there are some known bugs...
Wednesday, September 27, 2006
Max OS X Default Japanese Character Encoding/ Mojibake
When you send email using Macintosh Mail.app application, email does not show up correctly with your friends Hotmail or other accounts.
Issue:
In most Japanese language applications, the the character encoding must be Shift-JIS and not Unicode. This will cause a great bit of problem with Web and most of Microsoft applications.
Fix:
See Apple Technical Note at
http://docs.info.apple.com/article.html?artnum=301986
But basically you need to set some system defaults manually via the Terminal.app that is not available from the system's control panel. After opening the terminal.app type in the following string.
defaults write com.apple.mail NSPreferredMailCharset "ISO-2022-JP"
Tuesday, September 05, 2006
ASP.NET 2.0 QuickStart Installation Issue
But you might run into problems.
(1) How to install it.
Assuming that you've installed VS 2005 on the C: drive the installer is located in the following folder.
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\StartHere.htm
This will provide a link to the installer. But you might encounter an issue described in (2).
(2) Virtual Directory Registration Fails.
7:47:16 AM Tuesday, September 05, 2006: [Fail] Config_IIS_Install: IIS (Internet Information Services) Virtual Directory Registration (failed): [Fail] Failed to install ASP.NET Scriptmaps. Command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -s W3SVC/1/ROOT/QuickStartv20
Resolution for this one is:
First install and register ASP.NET with IIS:From the SDK command prompt run
aspnet_regiis -ir -enable
Then run C:\WINNT\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -s W3SVC/1/ROOT/QuickStartv20aspnet_regiis.exe should return a succes message.