Saturday, June 24, 2006

Enumerations in C#

Enumerations are a great construct.They allow you to create a type limited to a set of constant values. Because of this, they are type-safe. Best suited to use them are numerical values like int, long and byte.

The .Net framework makes extensive use of enums-Days of the Week, for example. Using enums eliminates common errors like passing invalid arguments to a function.

For example, you may have a function that accepts the numerical equivalent of a day of the week. It may only accept an integer from 1 to 7. But nothing prevents the code from calling it with a value of 8,9 or 10, etc. Using enumerations, you can define a custom type DayofWeek:

enum DayofWeek
{
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
}

So, instead of:
public void foo(int DayOfWeek)
{
}

we have:
public void foo(DayofWeek day)
{
}

By default, each constant in the enumerations will be given an integer value starting from 0. So Monday will have a value of 0, and so on.

Now you won't have to worry about your function being called with invalid arguments.



Till then, see ya!
Peace!

Wednesday, June 21, 2006

My so-called Lineage II Life

I play Lineage II on a private server. I've never played on retail but I think I have a fair amount of knowledge about the game.

I have 2 characters, a spellsinger and a Bounty hunter. The spellsinger came first. When you play on a low rate server, you have to think about which class to use as your first character. It's important that this character requires minimal equipment but can level up fast so that you can save more adena to 'fund' your next character.

So I chose an elven mystic character which later on became a spellsinger. Elven mystics are fragile but they more than make up for it due to their casting speed and fair amount of damage inflicted.

Why choose a mystic (a damage dealer mystic, that is), you might ask? Simple. It's because you level up faster. You kill more mobs faster and it's low maintenance.

After leveling up my mystic to 52, I created my real money-maker. A dwarf. More specifically, a scavenger dwarf.

You see scavengers make a lot more adena because of their spoil skill. They can get extra number of drops than any other character would normally get from a mob.

Leveling up a dwarf is hard, time consuming and most of all--boring! But if you want to make enough adena in order buy upper grade equipment(top C grade to A grade), a scavenger-and a warsmith, if I may add, is important.

BTW, I play on Staris server of L2 Extreme

Cya!
Peace!

Saturday, June 17, 2006

You are using an Invalid IP to access this site!

If you ever come across this error message on your PHP nuke sites, don't fret. It's just am error message coming from the nuke sentinel module.
Open nukesentinel.php in the includes folder and search for

if($nsnst_const['remote_ip']=="none") { die(_AB_INVALIDIP); }


Comment out this line and you're done!

Friday, June 16, 2006

Workshops and Training courses


I found some workshops that some of you guys might be interested in attending, especially those living in the South East Asia region:



--Training for PMP (Project Management Professional)
A 5-day training course to be held on July 17th to 21st in Kuala Lumpur.



--Software Architecture Workshop
2 day workshop to be held on June 29th to 30th in Manila



--Systems Engineering (for Technology Based Projects & Product Developments)
5-day workshop on July 24th to 28th at Singapore


All workshops are organized by ProcessWorks.

May I remind you that they're not free. hehehe. And I am not in anyway connected or related to the organizers of these workshops.
If you want to read the full course agenda and some additional details about the workshops, just post your email here and I'll email them to you. :-)

Thursday, June 15, 2006

Connecting to remote SQL 2005 instance in Visual Studio 2005

Visual studio is a great tool. It's the complete package for developing a multitude of .Net applications-from Windows applications to web applications. We even use it in developing our Symbian OS applications.

But along with these great 'powers' come some shortcomings. I was using Visual studio to connect and manage a remote SQL 2005 instance in our network. I have done everything to properly configure SQL 2005 to accept remote connections. I have enabled TCP/IP and named pipes thru the SQL Configuration Manager.

But for some strange reasons, there were times when the IDE just could not connect to the remote SQL 2005 instance. The error message says that by default, SQL 2005 do not accept remote connections to the machine or something to that effect. I am pretty sure that I have enabled TCP/IP and named pipes on the remote SQL 2005 instance.

I'm no expert but I presumed that since the remote SQL connections uses TCP/IP, I assumed that the IDE was using a port to connect to the remote SQL 2005 instance. And if the IDE cannot connect to the SQL 2005 instance using the port it was supposed to be using, then probably that port was already open and currently being used by another application on my PC.

I use a lot of applications on my PC like Yahoo Messenger, MSN Messenger, among other things. Then I decided not to load these applications (all apps which I knew were using ports) on my system.

Whoah! It worked! I've successfully connected to my remote DB server. Taking it a little bit further, by process of elimination, I narrowed them down to 3 apps: Yahoo Messenger, MSN Messenger and my peer-to-peer application. One of these 3 was the culprit. Sometimes it was yahoo which prevented me from connecting my IDE to the remote DB server, other times it was MSN.

Is there a way to set the ports that these applications use? Or is there a way to configure Visual Studio such that it will use a different port to connect to remote DB servers? I don't have answers to these questions yet, but rest assured that I will do my best to come up with a good solution to this problem.

Tuesday, June 13, 2006

Migrating .Net Windows Services to Windows 2000 problems

Today we tried installing a .Net windows service (a scheduler service) on a Windows 2000 Advanced Server box. The service used to run on a Windows XP box and was working perfectly fine. But since our target machine was Windows 2000, we had to migrate it to such.

Then, bam! The windows service just wouldn't install. We have tried recompiling it on the target machine, then install (using installutil.exe). Still, to no avail.

The first error we encountered was:

System.ComponentModel.Win32Exception: The account name is invalid
or does not exist, or the password is invalid for the account name
specified

The original configuration of the service was to use the Local Service account. We decided to change it to Local System. The service installed successfully.

But when we tried starting the service, we got a new error:

The service could not be started.
The service did not report an error.


Now there's a very 'descriptive' error message...Not!
I've tried looking at the Event Log but nothing really could help us out in diagnosing this problem.

Evaluating the situation, we now know that our windows service is installed, but it just would not start. And the error message could not really help us in moving forward to solving the problem.

At last I decided to use the third Account Type option - to run as it User.

this.serviceProcessInstaller1.Account =System.ServiceProcess.ServiceAccount.User;

Remember that for the Username property, we must indicate it in the format:
Domain\username.
I did not know beforehand that it was supposed to be that way. LOL! I kept using just the user name.

I created a new user account on the windows 2000 box with just enough permissions to run our windows service.

The installation using installutil.exe went smoothly. And lo and behold, the service started successfully! Phew!

I do not have a really in-depth knowledge of developing and deploying windows service. I am glad that we have solved this problem.

I don't know how come the service would not install when using the Local Service account under windows 2000 nor do I know how to solve the error occuring when I attempt to start the service after successfully installing it using the Local System account type.

Any ideas?
Now that the first post is over and done with, let me introduce myself. I am Edison Capiz from the Philippines. Currently I work as head of the web development department of our company. I cannot really say that I have a vast experience on developing for the web. I only started about 2 years ago ;-)

Mainly, I have focused on PHP, ASP and .Net. Most of the databases I have handled were either MySQL or MS SQL.

I just thought I could share some insights, experiences, rants, raves about my daily life as a developer.

Peace!

Friday, June 09, 2006

Muwahahahaha! My first blog :D