CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

November 2003 - Posts

  • DotNed meeting

    About 60 people attented yesterday's meeting of the DotNed user group. Just before leaving my office my first Longhorn startup screen came up and on the train-ride I had been reading .NET books bought on the PDC. I was totally on the right frequency for todays subject : the PDC.

    To kick off DotNed's Michiel van Otegem gave an overview of all the stuff presented on the PDC. He showed the startup screen of Longhorn, with a running clock, but alas he didn't get the intended demo working. His Longhorn installation worked on a moderate notebook under Virtual PC, switching off some of the Longhorn services, like licensing, makes it less resource hungry. I'm not going to repeat Michiels overview of the PDC. Last week I had been typing all that out for a submission for the sdgn, it will be on that site sometime soon. Michiel has some good contacts at Microsoft, quite noteworthy were his rumours on the release date of Whidbey : the beta on the Amsterdam TechEd and the final at the end of 2004. With Yukon coming possibly after that. VS.NET Whidbey makes a far more mature impression than Yukon. Besides that Yukon makes a big commitment to Xquery and that still has not been standardized yet.

    The second presentation was by Alex Thissen. Alex is a trainer with Twice IT, the hoster of the meeting. His first impressions of the PDC are allready on the sdgn site. For DotNed he did a very good presentation on creating asp.net Whidbey apps. It was long but still he didn't have the time to show all the new stuff. There is just to much. Alex created a new blank web-solution and added new components one at a time ending with a site full of advanced functionality. The most remarkable part of the show was that he didn't code a single line. Everything was done by setting properties and editting some xml files.

    To finish Bastiaan Beumer of  Hummingbird did a presentation on creating add-ins for VS.NET. It took some time for the presentation to take off as Bastiaan got a little messed up with the small screen resolution (800*600) which, in combination with all the VB.NET code,  led to a somewhat chaotic view. Having read (part of) the book his presentation was based on (Inside Visual Studio.NET) I knew where he wanted to go. At the end of the talk we all saw the ooh's and aah's of a VS.NET add-in. And the speaker showed his real nature: a developper. Thanks man, for having the courage to do a presentation.

    A good event is never complete without socializing. It was late but the snacks kept many of us on the scene for some chatter. Finally I met another dnj-blogger Jonne Kats who was the lucky winner of the meetings prize. The goodies table had a whole pile of new gems : Chris Sells,  David Chappel, Billy Hollis and Yasser Shohoud. Havn't seen them yet, so I don't know about any surpring side-shows. The trainride home was another pleasant reading.

    The next meeting is planned on january 22 2004. See you there.

    blog on,

    Peter

  • Busy day

    Today, the 27th, is going to be a busy day

    1. DotNed will meet again. In Amsterdam Sloterdijk and not Diemen ! Despite all I'm going by train again which will give me the opportunity to read. “Essential .NET“ by Don Box and “Applied .NET attributes“ by Jason Brock an Tom Barnaby (Apress) will get me in the PDC mood. Which is today's topic at DotNed.
    2. I succeeded in assembling my Longhorn machine and can start installing the bits.
    3. To keep my feet on the ground I have to write an updated proposal for an asp.net app. Which is fun as well. I always do short direct roundtrips with this customer. A written proposal, comments, updated proposal, after which I start building a prototype. Which leads to new insights what and how the app is going to work and results in more mature versions.
      The nice thing with a web-app that it is so easy to update, just one  place. I used to do Delphi apps for these people. Delphi apps are very simple to install, but have to be installed on every machine. One of the reasons we have changed to (intranet) webapps is that with the switch to Windows XP users' no longer have the permission to install anything at all. Now the system-maintenance department installs updates on the web-server. Which slows down the process.

    I'll start with the last item. And after all that's where the money comes from. See you at dotned

  • Growing up in public. (It's the document, stupid..)

    This post's title is the name of a Dutch theatre company. It would be a lovely title for a (my) blog as well. Recently I posted some blogs on xslt, some good feedback has well fed my insight. My main trouble was what part of a xsl stylesheet was data and which  part was code. A reply on another post made me realize I am old and suffering from some tunnel-vision myself. When looking at an xslt document I centralize on the xsl-transformer. How that analyzes the stylesheet and produces output. But what if I centralize my vison on the stylesheet itself ? It is a document and needs some code to fill in some of its parts. The difference is that it's not the code who is generating documents but the document calling some code. Which reminds me of the dos-windows transition, a dos program really owns the complete machine, a Windows program has to wait until it is sent a message. This scenario brings me back to the point where my wanderings started, IE (and not my .net app) opening a document (local aspx) and failing. Travelled in a circle but I grew a little older.

    blog on,

    Peter

  • Lost sight of your viewstate ?

    In a recent post I blogged on reducing the size of the viewstate. This has been a great success in the project and my default procedure has become to disable a control's viewstate right after dropping it on the form, only to switch it on in the cases I really need it. Like in a dropdownlist, to find out which item was selected by the user. There is a little gotcha here.

    When you disable a control's viewstate you also disable it for all child controls in the control tree. When you disable the viewstate of a page, the ultimate control, the viewstate of everything on that page is disabled as well. That's cool, that's easy. When you put a panel on the page and disable it's viewstate everything works well up to the moment you drop a dropdownlist on the panel and try to find out the item selected by the user. The selected item is in the dropdown's viewstate and that viewstate will not work untill you enable the viewstate of the panel-parent of the drop-down. Makes sense in this context but can be somewhat frustrating if you overlook the panel.

    blog on,

    Peter

  • Fixing a broken asp.net installation. (The Web server reported the following error when attempting to create or open the Web project located at the following....)

    After a failing installation of a VS.NET 2003 add-in, possibly because I  have Whidbey and 2003 running in parallel, I had quite a hard time to get everything working again. I found a lot of hits in support groups, a lot of solutions but nothing worked. The The Web server reported the following error when attempting to create or open the Web project located at the following .. (Internal Server error 500) message kept on hitting me whenever I tried to open or create a project.

    What finally helped was taking a closer look at the aspnet_regiis utility. In many solutions you are advised to use this with the -s option to register asp.net with your webapps

     -s <path>  - Install scriptmaps for this version at the specified path,
                  recursively. Existing scriptmaps of lower version are
                  upgraded to this version.
                  E.g. aspnet_regiis.exe -s W3SVC/1/ROOT/SampleApp1

    What finally worked was using the -i option

     -i         - Install this version of ASP.NET and update scriptmaps
                  at the IIS metabase root and for all scriptmaps below
                  the root. Existing scriptmaps of lower version are
                  upgraded to this version.

    RTFcommand line !

    <Update A summary and discussion of the many comments on this post can be found here. Read it !</Update>

    blog on

    Peter

  • Xwhat ? Xpath !

    This blog is a great way to organize my thoughts and has some great sparring partners, special thanks to Joseph Cooney. It all started with an involuntary collision with xslt, after which I tried to get a better grab on xsl(t). After rereading my books on the subject (Dino Esposito's applied XML programming (MS-Press), and Dan Wahlin's XML for ASP.NET developers (Sams)) I'll try to summarize what I have learned.

    Problem : Create an (XML) document out of an other XML-document.

    Approach 1 : Use a XSL style-sheet.
    An XSL stylesheet describes the layout of the output document. The stylesheet is composed of templates. When processing the input document the values of the document's nodes determine which template of the style sheet is used to transform the node. Selecting nodes is done in XPATH expressions, like MyDataSet/NortwindEmployees/Employee. The stylesheet and the the input document are processed by the XSLTransformer. To process multiple nodes XSLT has instructions like for-each, for conditional processing XSLT has instructions like if test and when. An XSLTransformer can be activated by IE which leads to a bang when it tries to transform an aspx page, which started my ramblings. According to Frans Bouma that is mainly due to the older XML engine of IE. The transformer can also be started from a .net application. The XML component uses it or you can program it using the System.Xml.Xsl.XslTransform class.

    Approach 2 : Use a XMLdocument object
    If you want to bypass XSLT you can approach in and output documents using the DOM (Document Object Model). The framework has the System.Xml.XmlDocument and the System.Xml.XmlDatadocument class. Objects of these classes can load an XML document, or another datasource, into memory. They provide a very rich programming interface to manipulate a document. A very interesting method is CreateNavigator(), the result of this method gives you the opportunity to use XPATH again to navigate through the (input) document.

    Approach 3 : Use XQuery
    This is a whole new ballgame. Xquery relates to XML as SQL relates to databases. Xquery has all the possibilities of XPATH and of XSLT, is predicted to swallow them, but is not available as an usable implementation yet.

    In the first place I am an OOP programmer. In the early days of .net, coming from Delphi,  I had been playing with the Delphi (t)XMLdocument wrapper class to catch XML datasets coming in over a web service. Which worked pretty well. Living in the .net world I am confronted with a lot more creatures of the xml family. Some, like xslt, scare me as they are somewhat difficult to catch. People rave about xsl(t), when specifying their delights they mainly mention the XPATH part of it. But XPATH is not limited to XSLT, in the .net framework it is also available when you're doing DOM-programing. And that's something I do understand, I'll use the second approach.

    Blog on,

    Peter

  • XSLT again

    My previous chatter on XSLT was possibly stated a little to strong. I do not want to ban every use(r) of it, I do even see places where it is useful. At the time of writing I was pissed of to be confronted with it without asking for it. The comments to my dislikes were quite interesting (thanks Frans an Joseph), reason enough to try to clarify my opinion.

    Let's take this XSLT sylesheet (From Dino Esposito's book "Applied XML-programming"

    <xsl:stylesheet
        xmlns:xsl:"http://www.w3.org/1999/XSL/Transform"
        version="1.0">

    <xsl:template match="/">
        <HTML>
            <BODY>
               <H1>Northwinds's Employees</H1>
                    <TABLE>
                        <xsl:apply-templates
                            select="MyDataSet/NortwindEmployees/Employee"
                    </TABLE>
                </BODY>
            </HTML>
    </xsl:template>

    Imho, the yellow part is just data, the processor will copy it straight to the resulting document. It is surrounded by xsl-code which will be processed by the xsl processor. Where the data stops and the code begins is completely unclear to the reader of the document. And even the XSL processor makes mistakes, like the one in IE trying to display an aspx document.

    To everything else than the xslt processor the whole stylesheet is data, after all it is just a XML document. A XAML file is a XMLdocument as well, in here the pieces of code can be recognized as being CDATA sections. A XAML file is no code, it is processed to generate the source of real C# classes, a CData section is not processed. This resulting source will be fed to the compiler to produce something executable. Here the distinction between code and (meta)data is a little clearer.

    The latter brings me to my other problem with xslt. The only development tool I really trust is a compiler. It will check every character of my source and immediately report on every typo or stupidity. When it comes to processing the style sheet I will not be aware of any problem until the crash has happened. So when I have a choice I'd rather use some XML(xpath)document objects. Of course this is partly a matter of taste. I am very strongly biased to stay away from xslt, but will it stay away from me ?

    Blog on,

    Peter

  • Another gem in the PDC pile

    Running through all the stuff I had brought home from the PDC I found a small disk : “Jeffrey Richter“. He's the author of the marvelous, must-read,  “Applied MS .NET Framework Programming” book. On the disk is also a full epsiode of  MSDN TV on C#. It is an issue of a couple of years ago with two interviews. The second one is with Jeffrey.

    The surprise on the disk is the first interview. It's my hero Anders Hejlsberg trying to convince the community on this new C# language and this new .net stuff. Quite historical, but every word still counts. Two quotes : “beta coming soon” (that was 1.0) and “In a future we will have generics in C#” (that is 2.0). The episode is no longer on line which makes the disk a must-have.

    blog on

    Peter

  • Dotnetjunkies site 3 : the cookie monster

    Cookies issued by the previous version of the dnj (or sqlj) site lead to failing links. After deleting all dnj (and sqlj) cookies from your local machine the site becomes far more functional. You have to log in again to be able to post blog entries. To make your comments track back again :

    • Enter your name in the name box
    • Enter the url to your blog in the url box
    • Check remember me.

    Blog on !

    Peter

    (Post updated after a night of upgrade blues)

  • Mixing data and code, the XSLT damage continues

    To start with a disclaimer : I am not hindered with much of practical XSLT experience. Mainly a matter of taste. But the technique keeps popping up over and over again. Every book on XML does cover it, there's a component sitting on VS.NET toolbox and a lot of MS apps do use XSLT in some kind of way. More on that later. XSLT is confusing to me because it does mix data and code. Code which was originally meant to format the presentation of the data but can be used to do whatever what. In .net you can even call methods of your own assemblies in an XSLT transform. I do like XML, it gives you a great insight how your data is structured and what it is supposed to stand for.

    A part of the talks by master Don on Indigo were on the separation of code and data. An object encapsulates data and has behavior in the form of methods. A message does not have any behavior. An object is a very nice thing to use inside your code as long as it stays in there. A message can be presented to the outer world. That is a clear story separating the two. I understand the sub-title of Don's blog as not to friendly on XSLT either, but maybe it is an over-simplification to lump these two matters. To keep on over-simplifying let's take a small look at XAML. In XAML you can store code in a CDATA section of a XAML file describing a component. Again you are mixing code and data then. Brent Rector takes a very strong stand against doing this in the Longhorn book. But even Don published a snippet where he did mix.

    After these theoretical thoughts (flame me out of here if it is bullshit) the actual reason for this post. I bumped into XSLT again where it tried to to something behind the scenes, didn't know how to solve that and presented me with something which had me puzzled for quite some time. Internet Explorer uses XSLT without us noticing it. The result is quite nice when you open an XML file in IE, but the result is a horror when you try to open an aspx file via a local path, not via http. The main menu of an app I'm working on is a plain index.htm, I use Frontpage to try to make it look pretty and use plain hyperlinks to the aspx pages. Works like a snap until you open the file locally. It folllows the link and will try to open the aspx. There is no IIS between the request and the file and what happens is that IE tries to perform a transform and fails.

    The XML page cannot be displayed

    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    A name was started with an invalid character. Error processing resource 'file:///C:/Usr/SU/MOC 1.0/Systeembeheer/Menu.aspx'. Line 1, Position 2

    <%@ Page language="c#" Codebehind="Menu.aspx.cs" AutoEventWireup="false" Inherits="Systeembeheer.Menu" %>
    -^

    I don't blame my local disk for not acting as a an IIS, I do blame IE for this stupid message. A little Googling showed me this does happen in a lot of other scenarios as well. Leaving a lot of people puzzled. And it is a code and data mix-up. But the code was not intended for XSLT but for the ASP.NET web-server.

    Blog on,

    Peter

  • Longhorn hardware requirments

    I want to upgrade my gameboy to install Longhorn. Dedicated, no virtual PC. I consider a 2.6 Ghz P4, 1 Gb of RAM and an off-the shelf GeForce Radeon graphics card. Does anybody have any experiences with Longhorn he or she would like to share on this ?

    blog on

    Peter

  • DotNEd wil meet again

    The Dutch .NET user group will have a new meeting on the 27th of november. All info and registration over here. This time the meeting is in Diemen. I am not sure what kind of transportation I'm going to use. Anybody interested in a carpool leavinf from Groningen ?

    Zie jullie daar !

    Peter

  • My datalist article is up !

    My article on a custom datalist control has the honour being the first one on the new dotnetjunkies site. There are some 1.0 difficulties. All articles on the dnj site have (temporary ?) moved, so most links in the story are dead.

    Enjoy,

    Peter

  • Do you really need this Viewstate thing ?

    I spent the last days mainly on the ViewState. Read a lot about it and tried even more things. Quite interesting, often very frustrating, but worth a roundup which leads to a positive conclusion. Lets' start with a small recap. The viewstate of an asp.net webpage is the vehicle in which the state of a web page travels. When the user posts a page back to the server the server will return a new copy of the webpage in which the state of all controls, like the text in a textbox or the contents of a datagrid, is preserved. This state is encoded in a hidden form field on the page named __ViewState, you will see it when you do a view source in your browser. This field is included in the response coming from the server but also in the request posted back to the server. With the state (-changes) stored in the html page the webbrowser plays an important role in state mangement.

    Almost every property (-change) of a webcontrol is stored in this viewstate. One of my apps has pages with many row datalists, the size of the request alone sometimes exceeded 100 K ! Which resulted in a not so snappy performance and was the main reason for my investigations. My first attempt was to completely get rid of the viewstate. The System.Web.UI.Page has two methods which deal with its persistence. Both are virtual an can be overridden.

    protected override void SavePageStateToPersistenceMedium(object vs)
    {

        base.SavePageStateToPersistenceMedium(vs);

    }

    protected override object LoadPageStateFromPersistenceMedium()
    {

        return base.LoadPageStateFromPersistenceMedium();

    }

    The default base implementation of the first method stores the serialized viewstate in the hidden __viewstate field on the page and the second retrieves the viewstate from the page. On the web I found several people who had overridden this method to store the viewstate in the session instead of the page. The viewstate data then stays on the server. Some solutions were pretty straightforward, they used one session variable to store every viewstate in the session. Which could work as long as the session has only one page open. Another implementation recycled an array of multiple states and another one even maintained a dynamic collection of sessions vars, one for every url. Especially the latter will lead to gigantic scaling problems. Just imagine a user having an all day session visiting a couple of hundreds of pages. It only takes a couple of those to cripple any web server. I am not giving you any links to these sources, besides their theoretical issues they just do not work. I also use the viewstate in my code to store some of my own stuff. Maybe that is the reason, maybe something else, but I experienced that every viewstate given back by the session was screwed up.

    Another solution to get rid of the viewstate hog is to disable it. Every control (including a page) has an EnableViewState property. Default this is set to true. The most pages of my application contain a DataList component with database data. This dnj article describes the idea. In the article and its precursor on the DataGrid I already mentioned some thoughts on the viewstate. As the data in the list are re-read on every roundtrip they do not have to be persisted in the viewstate. The bad thing is that setting the list's EnableViewState property to false screws up the working of the EditItemIndex and SelectedItemIndex property. You can try to handle those properties in your own code. The DataGrid  and the DataList components have an SelectedIndexChanged event which will get fired on an index change and they do receive the correct new index in the event's arguments. But the bad thing is that these events get fired too late. In my article was an overview of the events on a page roundtrip, the problem is that the components only render as desired when the index is set in the initialization events, like Init. The SelectedIndexChanged event fires later, setting the SelectedIndex property in there will result in a correct rendering of your component on the next roundtrip. Not really a desired behaviour. The EnableViewState property of a DataList or DataGrid just has to be enabled for the controls to be usable.

    The good thing with the EnableViewState property is that it can be disabled on almost all other controls. The data is presented in (data bound) text-boxes and labels in the templates of the list and is reloaded in the DataBind of every roundtrip, so they do not need the viewstate. For linkbuttons and normal buttons it is almost ridiculous to have a viewstate, except when you want their appearance to change over roundtrips. The only controls which really do make a sensible use of the viewstate are (dropdown-)listboxes and treeviews. If you disable their viewstate you will not be able to see which item was selected by the user. It would make sense to get  the contents of the list out of the viewstate as that will not often change over roundtrips, more on that later. After a lot of property editing and testing I was disable the viewstate for most of the components. The result was great. I tested the viewstate size by looking at the size of the request :

    Response.Write(string.Format("

    RequestSize {0} Bytes

    ", Request.TotalBytes));

    On some pages it resulted in a reduction of 90% in the size of the request and 50% in the size of the response. Without the loss of any functionality. The next question is how the app will behave on the intranet of my customer.

    This ViewState matter has also been adressed in Whidbey. In there a control has besides its viewstate a controlstate property. The controlstate is used to persist those properties which are essential to a component. The controlstate cannot be disabled. The ViewState is still there as well. But after all, the only real problem is that it is enabled by default.

    Blog on,

    Peter

  • New FeedDemon

    There is a new feeddemon avalaible for download. A cool fix is that doubleclicking the fd item in the taskbar now does restore. My back and front mouse buttons still don't work, a discussion in the feeddemon newsgroup explained why. I still wander why those buttons do work in Vs.net ? Anyway, that's my little problem, on all other points it's a great product.

    blog on,

    Peter

More Posts Next page »