Jase's Blog
in

dotnet.org.za

South African .NET Developer Portal

Jase's Blog

K2.net, Development, Architecture and the Machine
  • VBA.Collection to .Net NVC!

    Here's the situation: we have a legacy COM component that is nice enough to pass us back a VBA.Collection.

    No problem, just cast it - only you can't! In between the COMExceptions and InvalidCastExceptions I read this on Microsoft's MSDN: here. Informative, but I was doing things the other way round. So, after trying to cast VBA.Collection to just about everything else *grrrrrr* I rolled my own - so to speak:

    Bear in mind that this is VB.Net and you must turn off option strict due to late binding to COM to get this right (this is not ideal, but I am now out of time - any idea's, please let me know!)

    Here's the code:

    Private Function ConvertColToNVC(ByRef vbaColl As VBA.Collection) As NameValueCollection

          Dim nvc As New NameValueCollection

          Dim objCol As Object

          'for each item in the collection do the conversions:

          'i.e nvc.add("Originator ID","333210")

          If vbaColl.Count > 0 Then

                For Each objCol In vbaColl

                      nvc.Add(objCol.name, objCol.value)

                Next

          End If

          Return nvc

    End Function

    It almost seems like you should just be able to do a direct cast from VBA.Collection to NVC - but alas no joy!

  • Naming Standards for .Net

    Finally, concise, precise and looks good too - for coding standards in .Net check out: here! . Very good article about half way through the page - I hope not too many of you recognise the varible names!!! ;-)

  • ASPX Session Redirects

    It all started out as a day of fighting the clustering decision makers when my PM comes to me with this issue in live. The issue turns out to be a session expiring and the code not handling it very well. This is all well and good, but the scenario is quite funny: the user starts completing a form, and then gets a modal window up (for our date picker) and instead of just selecting a date, our user goes for a coffee. (Admittedly, we probably would too!) Gets back, selects the date and continues! However, the session time out for us is the default 20 minutes. A cup of coffee seemed to take a little longer! There is a solution to this: here!

  • Got an AMD 64? Don't install SP2 - YET!

    MS are working hard to resolve a challenge with their Win XP SP2 on the AMD 64 bit platform (On CNET News.com here!) - the current suggestion is: don't install just yet! But only if you are the few who have an AMD 64...
    Posted Sep 01 2004, 06:52 AM by hi_jase with no comments
    Filed under:
  • Clustering - off the topic: BeoWulf

    Ok this is getting silly, I know, but if any of you are academically minded then check out: here! - on how to create a BeoWulf cluster!
  • Boy Scout meets IT Pro

    I just had to - made me laugh: check it out: http://www.thinkgeek.com/gadgets/tools/6b3b
    Posted Aug 27 2004, 11:47 AM by hi_jase with no comments
    Filed under:
  • Clustering 101 - decision time

    In the long saga of clustering we are now at a decision point. Do we go the high availanlity route, or the high performance route. This is way too long for a blog, so check out the article: here!
  • Clustering 101 - Part 3 (the NLB angle)

    Welcome back! The saga continues. Due to the hardware requirements and failover requirements as in the previous post (click here) I have ventured down the NLB (Network Load Balancing) angle.

    Given the environment (.NET 1.1, SQL Server 2000, Oracle 9i, K2.Net 2003 and NDS), the NLB with SQL Server using Log Shipping may or may not work. Admittedly we currently feel that there are some risks. Mainly around hot swapping configs for the .Net app and K2 if a certain conditions arise and issues with what currently seems a requirement for manual db roll forward on the primary env if the primary env dies and the 'warm' SQL Server takes over. More on this angle later.

    Also, there are a couple of meetings scheduled with the people in the know - specifically the helpful guys at SourceCode (K2.Net) - the creators of K2 - regarding K2.Net Server and clustering with high availability.

    References at this point are: Win 2K NLB Technical Overview - MS says same for Win 2K3 and SQL Server 2000 NLB High Availability Series

    I'll keep you posted.

    Later

     

  • Clustering 101 Part 2

    For the Windows Cluster, the following clustering technology is available:

    1. Network Load Balancing (NLB)
    2. clusters Component Load Balancing (CLB)
    3. clusters Server clusters

     

    Cluster Component Load Balancing is irrelevant in the current context as it applies to Microsoft Application Centre. This leaves us with 1 & 3.

    The remaining options for 3 are the following cluster models:
    Model 1: Single node server cluster configuration
    Model 2: Single quorum device server cluster configuration
    Model 3: Majority node set server cluster configuration

     

    Model 1 - is more for organisation and does not support failover. This does not help us.
    Model 2 - this requires a seperate single quorum drive. All the servers access the shared quorum drive. Given our hardware: 2 full Dell servers, this will also not help.
    Model 3 - now this looks promising, we can use the existing server as they are with no special hardware requirement, however it still does not help us a the "Maximum number of node failures before the cluster loses quorum" is 0 for only 2 servers. Hence, if one server goes down, the other will not be able to carry on.

     

    This takes us back to the concept of network load balancing across the 2 servers. There are more options available at this juncture, but we will explore the NLB across the servers first.

     

    This information is available in the Win 2K3 documentation installed with the server. Usually in C:\windows\help\mscsconcepts.chm

  • Clustering 101

    Hi

     

    With any luck, during the course of this blog catergory, we will discover some do's and don't regarding a clustered setup. First, let me admit that I am a developer and that this is my first cluster. The idea of this is that after reading pieces of relevant (perhaps seemingly) information, I will add them in posts to help potential clusteree's. If I start going off on a tangent, feel free to help steer the situation. Bear in mind that this is a development cluster, the live migration will only be in 3 to 6 months, so trail and error are fine.

     

    First up, where we are and what we want to acheive...

    The Goal

    Maximum uptime and high availablity. The idea being that if a server in a cluster goes down, then the other one will carry on. Clients may experience degraded performance, but not a denial of service.

    The System

    2 Dell 2650 Dual Xeon processors both with 2 Gb's of RAM and RAID 5. Both on the same network and both behind a NLB (Network Load Balancing Device).

    Software Components

    Windows 2K3 Server

    ASPX VB.Net application on IIS 6.0

    K2.Net 2003

    Oracle Client --> Server is on a different box (9i)

     

    The Issues

    1. How do we setup a Win2K3 cluster?

    2. How do we setup a SQL Server cluster?

    3. How do we setup a K2.Net 2003 cluster?

    4. How do we setup the web app on this cluster? (remember, in a web farm scenario, ASPX requires something to manage the sessions --> SQL Server)

    The idea is that as time progresses, these questions will be answered and content and links will be posted.

    Later

  • The ET Weekend Run

    Yes, you can get a sunburn in winter. Although how I managed it with a lid (helmet for you non-riders) on all day I have no idea!

     

    The weekend stint (photo's should follow with any luck, sadly no time for high speed pass photo's - we were too busy doing the riding!) in ET was awesome. ET = Eastern Transvaal. It started out a little rocky though. Have you ever tried renting a bike trailer? No, well Friday was a first for me too. After considerable hunting I got hold of a place in PTA - Waverly Trailers. No issue, they have definatley got a bike trailer. Great. Can it take 2 superbikes? No problem, 2 will fit on it easily. So we set off, with bikes and tie downs - and a car for the trailer. Before I get any flak here, I know that a trailer drive to ET sounds whoosy, but consider the fact that bikes are priced exactly the same as cars on toll roads. Enough said... Ok, so our 'bike trailer' turns out to be a flat bed trailer with sides. <later that night> We have eventually had the best out of a bad situation and rigged the two bikes on the flat bed. Yes, securely. (They did make it all the way there and back). The bikes in question are both V-Twins: a burnt copper Suzuki SV1000s and red Suzuki TL1000s. My personal opinion is that you can't beat a V-Twin in the twisties. ('Twisties' is a nick name for chicane type corners). The rigging took a long time, so... <Still later that night> We set up camp at 1am. But of course, breakfast first. You can't beat a cold beer and a plate of bacon and eggs at 1am! Luckily we were the only people in the camp site.

     

    So, we are up again early - got to get that cold air over the bikes for best performance. By the way, my TL is running at 110 BHP with 101 Nm. An awesome machine. And off we are on the roads again. First up: Graskop --> Sabie. (And back again...) the scenery is great - you need to be sure to keep yours eyes on the road. Now we have some heat in our tyres, we head off to Hazyview. I'm leading and get a little carried away (remember, it is Saturday and the rugby is on at 15H00!) So, from Hazyview, the long way round to White River, a quick stop to take stock of things and off back to Hazyview via the R40 - really nice high speed sweeping corners with plenty of run off just in case. Excellent. Get back to Hazyview, I need fuel (the 3rd time this weekend), the SV fills up too, but only needed 1/2 a tank! Much better fuel consumption on that piece of kit - maybe I ride a little too hard, but hey, it's fun! It is now time for the pub, but wait - we need steaks for the braai! So (quickly) off to the Spar - we just about need to fight through security as it closes at 15H30! Can you believe it?! Needless to say, rugby gets sacrificed for steaks and bike rides (we still won!). That night runs rather late with some excellent steaks and low temperatures.

     

    The next morning: we decided to take the roads we already knew, then didn't! Kowie pass was on the books - tight and technical corners at the top with sweeping high speed runs at the bottom. Also excellent. A quick break on the way back to laugh with the people at the big swing - at Mogodi Lodge, you wear a full body harness and do a 15m freefall into a 60m gorge. At the extent of the free fall, the cable tightens and you swing from one side to the other. Single or tandem, you decide. So we opted for the bikes. Breakfast at Harries Pancakes. God's Window (nice twisties again) and all the bins are sign posted (“Please keep God's Window clean“). Admittedly we found this very amusing. Of course, we obeyed the signs too! Then off to Bourke's Luck Pot Holes. We enjoyed the run so much that we nearly ended up in Orighstad - admittedly we sort of missed the turn off, but we were having fun! Bike needs fuel yet again!!! Only issue with hard riding on a 17 liter tank is that the range sucks.

    Once done at Bourkes - another run back to Graskop and (sadly) it was time to break camp. Once this was accompished, we had to get the bikes onto the trailer and strap them down. The run from Graskop back to Jhb was near on 6 hours. Bed time at 1am and up at 5am. I am now tired and need another weekend! Morning everyone...

    Posted Aug 23 2004, 08:09 AM by hi_jase with no comments
    Filed under:
  • Optimising Strings in .Net

    Hi

     

    Our development team was trying to decide when to use a concatenated Strings and the StringBuilder. (The StringBuilder can be found in System.Text). All code examples are in VB.Net. The rule of thumb that we are going to use is: when you concatenate 2 strings, standard string concatenation is fine, but the second there are more: use the StringBuilder.

    VB.Net : String

    dim strMine as string

    strMine = “Development”

    strMine = strMine.concat(strMine, “ Team”)

     

    So what happens here? VB.Net takes the original strMine as 'Development' in RAM and creates a copy in of it in RAM with the concatenated value of 'Development Team'.  The previously used RAM is now available for the GC (Garbage Collector). Fine, but what about the StringBuilder?

     

    VB.Net : StringBuilder

    dim sbMine as new StringBuilder

    sbMine.Append(”Development”)

    sbMine.Append(” Team”)

     

    And here? Well, the StringBuilder points to an area in RAM, this section of RAM is not copied and set for the GC the second there is a change, but the actual information contained within the section of RAM is modifed. Note: to get your new string from the StringBuilder, you will need to use: sbMine.toString() I.e. in the first example, not only do you use more RAM than you require, you also have an extra object that requires a run from the GC. Not to mention the extra CPU cycles required to (a) make the object in the first place, (b) create of copy of it and (c) remove the dead string from RAM. So obviously it is faster, but why bother on such a simple example, how much extra RAM does this really take? Well, to be fair, given the example, in this case you would see little performance gain if any, hence our rule of thumb. That said, consider the changes when you start writing web controls, or start streaming server side generated HTML. It becomes a very different ball game.

     

    For an example of real time speed improvements, please see the following article in the MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvbpj01/html/gs0107.asp

     

    I hope you find this useful, comments, suggestions and feedback welcome. Also, if there are other samples relating to the performance gains, feel free to add them.

     

    Later

  • Oracle's Managed Data Provider for .NET

    Hi

     

    I don't know how many of you guys use Oracle databases from a .Net platform, but for those of us that do, Oracle have released a seemingly nifty version of a data provider for .Net. Previously we have only had the MS version of this - which works very well, bar an irritating memory leak. The leak is relativley isolated and is therefore of little consequence to us. Either way, the Ora release seems jam packed with some cool features with native support for XML (this was possible anyway, but with a bit of effort). For those interested, check out: http://www.oracle.com/technology/tech/windows/odpnet/index.html

     

    The data access from .Net's side is almost exactly the same as the current MS provider, or for that matter, the SQL provider for SQL Server access. So near zero learning curve here!

     

    Later

  • Welcome

    Hi all and welcome to my first blog.

     

    For the first item on my agenda I'm going to add something really simple, but that helps me quite a bit in my general day as a developer.

     

    I'm sure that all you developers out there are familiar with IE and Google (http://www.google.com). Now, with IE there is a very simple way to get there (apart from a quick link, or a favourite!) - type google in the address bar and hold CTRL and hit enter. IE will complete the http://www. and the .com for you automatically. Now that we are at Google, time for the Google tip... Have you ever been sitting in a meeting and someone shouts out some odd term or acronym that no-one's ever heard of? Well, Google probably has: type in: Define: keyword and hit enter. Google provides you with a list of possible definitions for your previously unknown word or term. Have fun!

     

    Later

    Posted Aug 11 2004, 11:20 AM by hi_jase with 6 comment(s)
    Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems