From My Desktop to the Internet!

Name:
Location: Rowland Heights, California, United States

Thursday, March 31, 2005

C# New Line Carriage Return

You ever wonder why the .NET Development Team didn't just put the escape sequence characters into Constants? Well they did... Sort of!

Here are two samples of code that do the same thing:

// First Sample
StringBuilder sb = new StringBuilder();
sb.Add("This the first line,");
sb.Add("/r/n");
sb.Add("Here is the second line.");

// Second Sample
StringBuilder sb = new StringBuilder();
sb.Add("This the first line,");
sb.Add(System.Environment.NewLine);
sb.Add("Here is the second line.");

Notice how instead of using the escape sequence characters in the second example I used a built Constant that the .NET Team Provided for you and I. This method is so much cleaner and so much more understandable. This works great when you're working with someone that is new to the .NET Framework.

You should also check out what else they have the System.Environment Class.

Here's a link where you can get more escape sequence characters.

Wednesday, March 30, 2005

Simple Ways to Create a New Record Using Mere Mortals.Net

When adding a new record using a Mere Mortals.Net Business Object be default it doesn't automatically display the empty record on a form or the "pointer" doesn't seem to be sitting on the new record.

There is a couple way to take care of this issue:

1 - you can put code in the hookpostnew method of the form and use the bindingcontext object to display the last record of the dataset.

2 - if you don't have a grid on the form and you only display one record at any given time you put code in the hookprenew method to clear the dataset.

Tuesday, March 29, 2005

Catch All Error Trap for ASP.NET

Trying to trap every error in code if virtually impossible - but in ASP.NET it's as easy at 1, 2 and 3!

Generic error trapping is important when it comes to Web Applications so you know something wrong is happening with your web site.

In most cases you want to put your code in the Application_Error event handler of the Global.asax file. There is plenty of information that you can access in that method.

For starters, you can check the sender and e objects sent as parameters. Those can provide some useful information. You can also call Server.GetLastError(). Another thing to do is create a NameValueCollection Object and gather all the environment variables.

After you've done all this you can either save it to a file, log it in the event log, email it to yourself, etc...

Hope this helps you!!!

VSS Over VPN Connections...

For those using Visual Source Safe over a VPN Connection or thinking about using a VPN Connection here are some tweaks you can do on your VSS Database to make the VPN Experience more enjoyable.

For starters, set the temp and data paths to point to the local drives on the user. You have to be cautious when using these settings. Everyone has to agree on a directory structure otherwise VSS won't work correctly.

Also, set VSS so that it doesn't list the files automatically when accessing VSS - you have to know what you're going after or double click on the folder in VSS if you want to see what's in it.
These settings can be found in the srcsafe.ini file located in the installation folder. Be aware that whatever settings you make here will cascade to all users in VSS - this may not be the behavior you want. If so, modifiy each user's ss.ini file independantly located under the VSS Install Folder\users\{username}\ss.ini - I can't caution you enough when modifying these files. Make backups, double backups and triple backups. If VSS doesn't like what it sees it won't function correctly.

The settings you want to modify are:
data = {some local folder on your desktop}
temp = {some local folder on your desktop}
CP_OnSelection = {yes/no}

Other stuff we do is archive on a regular basis to try to keep our VSS Database under 1GB as well as run integrity checks every week. This will keep your VSS Database healthy and you can catch issue early before they cause any major problems, slow downs or the most feared event a developer can experience while living on planet Earth: Data Loss!!! :)

The machine doesn't have to be an extremely fast machine but what does help is a lot of memory (about 512MB or so), a fast hard drive(s) (preferably 7200RPM SCSI Drives with a fast seek and a lot of buffer) and plenty of work space on the drive (especially when performing maintenance). Maintenance should always be performed locally on the VSS Machine to avoid network traffic and performance issues while doing maintenance on the database.
Most of this information I got from this place call the Internet - it's very cool!!! :)

Here are some links:

MSDN
VSS Preferrence
VSS Tips and Tricks

Friday, March 18, 2005

Subclassing Third Party Frameworks...

Subclassing is the easy part, keeping all the designer functionality is gonna to be the time consuming part. The reason is because in order to keep all the designer functionality you'll have to go back in fill in all the appropriate attributes for any code you extend or override.

My recommendation is to use the controls as is - in other words don't create a subclass of every MM.NET control "right off the bat". If later you feel you need to add a superclass in between your class and an MM.NET Class you can simply do so by changing your code. It's not like in VFP where you had to hack the table and add code like superclass::mymethod(). .NET is a lot more practical when it comes to changing a superclass.

Besides, that's what frameworks like MM.NET are for... Let Kevin worry about the features. Go on! Have fun working on the FUNdemental part of your project. Stop worrying about what features you'll want to add to the framework. :)

In the 8 years that I've been working with Kevin's frameworks I've never had to subclass *ALL* his classes... In fact, the occassion was rare.

Thursday, March 17, 2005

Deploying Mere Mortals.NET Web Sites...

When working with Mere Mortals.NET Framework you have to pay special attention at how you reference your assemblies.

By installing the Mere Mortals Framework you are installing all the assemblies into the Global Asembly Cache (GAC). Therefore, when using Visual Studio.NET Copy Utility it's gonna assume that you would like to use the GAC'ed assemblies on the target server. Visual Studio.NET trying to be overly helpful doesn't copy the MM.NET assemblies.

If you don't plan to install the Mere Mortals Framework on your production server or your using a hosting company that probably won't let you install any third party components you may need to toggle a property on your reference.

The way to do so is to right-click on the MM.NET Reference and choose properties, change "Copy Local=True". This will tell Visual Studio.NET that you want to copy the assembly to the target server locally.

Friday, March 11, 2005

nGallery is in the works...

So during the week we had some problems here at work that involved security. Once we got all that squared away I decided to go back and play around with nGallery since the last time I tried to get that to run on W2K3 fell a little short of success.

I got nGallery running in a sub-domain of http://www.vicandbert.com called http://ngallery.vicandbert.com - I have tons of pictures so it'll take me a little while to get through all of them.

I see some improvements that I can probably contribute to nGallery so I'm gonna check those out, too. Now I just have to find the time.

And by the way, website are up and running without any problems. New Netgear advance firewall router is very nice. I'm very happy with it.

Thursday, March 10, 2005

Web Sites being down...

Lately my websites have been down because I followed directions.

For the most part Linksys routers are pretty stable. The router I had as model number BEFSR81 V.2 - I had this router for about 4 years until it finally broke down.

The router would sometimes give me problems here and there but not to the point where it was unusable - it was more annoying than unusable. I'd say it probably needed to have the power recycled about once a week... maybe two weeks.

Until about the fourth year... Collission lights would be more apperant, Diag light would get stuck, etc... I decided to upgrade the firmware but before doing so I visited the local Linksys forums to see if there were any issues. For the most part people were pretty happy with the upgrades. So I upgraded to firmware version 2.45.0.1 June 2004 (something to that effect).

Things just began to get worse - the router was almost unusable. I get Linksys on the horn to find out what could've gone wrong. Right off the bat I ask the technician if it was time to buy a new router but he assured me that everything would be just fine. With a few tweaks her and there we'd be up and running like a the Rodent in the Wild E. Coyote Cartoon. So we modified the MTU setting to be 1200 - previously I set it 1493 since that's what the forums indicated was an optimal speed for DSL users. NOTHING! Still having the same problem where the router Diag light would get stuck for 10 to 15 seconds at a time. The technician didn't seem worried so I wasn't worried. Again he said, "No problem, with another upgrade I'd up and running in no time." I download another copy of the latest and greatest firmware for V.2 of the router and flash it, again. This time around the router Diag light blink at a steady pace. Still the technician said, "No problem, sir. We just need to unplug the router for about a minute and everything should be fine."

So, during the minute the technician and I became acquianted with one-another. Through the conversation we determined that it was 11:00 pm in California (where I was) and it was 2:00 pm in India (where he was). We talked about the weather, weather patterns, laugh a little with a few cracks I threw at him - a minute takes a little longer than one would think.

Anyway, I plug in the router and the light still blinked just as steady as before. Then he says, "Sire, you mentioned you were thinking about buying a new router?" I fell to the floor laughing my "efen" ass off - not to mention that he just started busting up with laughter, also.

Anyway, after I laughed and cried and pondered on how to get my websites up I finally just went to bed.

My website have been down for 3 days in a row. I finally purchased a new Netgear Advance Firewall FVS318 (very nice by the way). I'm still working out the tweaks. Hopefully I'll have my sites back up and running soon.

http://www.danyvibe.com
http://www.vicandbert.com

Try to visit them and let me know they work once in a while... Happy coding!!!