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

Jeffrey Palermo (.com)

Blog moved to www.jeffreypalermo.com

August 2004 - Posts

  • New "Make" build-type in Whidbey - level 100

    I've been using VS 2005 Beta 1 on a project, and the build seems to be a bit slow on starting, but there is a new context menu item called “Make”.  As far as I can tell, it builds the project just the same, and it does it WAY faster than “Build” or “Rebuild”, so that's what I've been using to avoid waiting for the delay.  The bugs are currently being worked out of the build process, so I'm sure it'll get faster. 

  • Integrating .Net v2.0 Beta 1 with v1.1 - it's working! - level 200

    It's working well.  My team has an extensive v1.1 team framework of common functionality, so since I've been developing a web app with ASP.NET 2.0 Beta 1, I've started on a v2.0 team framework.  Right now I only have 3 new classes, and I just reference the rest of the framework through the v1.1.  It works well, but there is one caveat.  When  used by the client application, you need to have all required .dll files in the bin folder, so we have our version 1.1 framework “TeamFramework.dll” and the v2.0 compiles to TeamFramework.dll also, so what to do?  Well, the easiest thing for me is to set the v2.0 project to compile to TeamFramework2.dll, but that was an issue.  Now, of course, putting these in the GAC would solve this problem, but our application doesn't require the GAC.

    All in all, the two versions inter-operate very well.

  • Feedback request: For what should your Systems Engineer be responsible? - level 100

    I realize that in small companies, the developer also has to be the System Engineer and is completely responsible for the server, but in larger enterprises, these responsibilities are assigned to dedicated teams.  As an enterprise developer, I'm on a team that develops and applications, deploys it and supports it.  We have an SE and DBAs that are responsible for maintaining the actual servers, but sometimes support issues get come to us when they really should be the responsibility fo the SE or DBA.  Suppose a database job fails, shouldn't the DBA be responsible for that?  The code didn't change.  What if an application server mysteriously stops responding in production?  Is it the SE's responsibility to determine root cause?  These are issues facing my organization, and I'd like some feedback regarding your teams and your interaction with your SEs and DBAs.
  • Please provide feedback to the Whidbey Team - level 000

    The MSDN Product Feedback Center is looking for feedback.  Please provided feedback concerning how Whidbey can be made better before RTM.  If you are using it, please log bugs and suggestions.
  • Named DataGrid columns - wouldn't it be nice? - level 300

    Earlier, I blogged about using controls that are embedded in unusual places in the control tree of the DataGrid.  For instance, putting a LinkButton for adding a new record in the header or footer of the DataGrid.  You have to manually manipulate the Controls collection to do this. 

    Another issue is what if you put that LinkButton in the same column as the Edit, update, cancel, delete buttons?  If you want to restrict editing of the data, a step on the UI would be to hide that entire column.  Seems pretty straight-forward, but how do you get a reference to that column?  I searched, and the only way I found was to reference it by the index in the Columns collection:

    dgd.Columns[7].Visible = false;

    That works well, but it bit me in the butt when I tried to maintain that code.  Down the road it became necessary to add two columns to that DataGrid.  Then, you guessed it!  A nice, little bug in my code.  Usually I'm able to avoid the debugger in VS by writing modular code and using the heck out of the ASP.NET Trace feature (great for code maintenance), but this was an issue that actually required a breakpoint.  Once inside the code, it was very clear what was happening.  I changed the index to the new index of the edit column, and my problem was fixed (until next time), but isn't there a more maintainable way to do this?  What happens when another developer needs to modify my application.  Yeah, I document the heck out of it, but why can't the Columns collection support column name identifiers as well.  I know the answer (CollectionBase), but it would be nice.

    For now, I'll have several lines of comments above that code. 

  • Lutz Roeder's Reflector for .Net - level 300

    I recently downloaded and used Lutz Roeder's Reflector program, and it is a pretty sweet tool.  VS 2005 Beta 1 has the class browser just like VS 2003, but the disassembler is what make Lutz's tool so useful. 

    The disassembler takes the compiled MSIL and converts it back into its best guess of C# or VB or Delphi (you can also view the IL).  Using that guessed code (which is VERY accurate), you can find out how a method was implemented.  It can be used on .Net Framework types as well.

    It saved me a lot of time just today.  I knew I need to use a certain object in a predefined assembly, but I didn't know how the class was intended to be created.  There was a constructor with parameters for all the things that needed to be populated, but I didn't know all that information.  Using the disassembler on another class in that assembly that used the object in question, I was able to see that a completely different object is in charge of instantiating my said object.  Now, I can easily creat my mystery object, and Lutz has saved me time.  Thanks!

  • Using static classes in .Net 2.0 - level 300

    In .Net 1.0 and 1.1, we got used to creating a private constructor if we wanted to prevent someone from creating an instance of our class.  If we did not define a constructor, the default constructor was compiled for use, and the user could create an empty instance.  So we prevented this by creating the private constructor.  In C# we have classes, but in VB, there are classes and then modules which can contain only static (Shared) methods.  In .Net v2.0 Beta 1, C# can have the static keyword applied to classes to prevent them from having instances.  Now, I've deleted my private contructor and applied the static keyword!  There's not going back now!
  • "Best Practices" change from version 1.1 to 2.0 Beta 1 - level 200

    For those of you who use FxCop, beware of version 2.0.  Actually, look forward to version 2.0 and jump for joy, but it would benefit you to learn about version 2.0 now so that you can prepare to move to the next version.  I've migrated some v1.1 code I wrote last year to v2.0 Beta 1.  I had run FxCop on my assembly last year, and I decided to follow all the Microsoft Recommended conventions.  That included NOT using the default overload of the .ToString() method.  Instead, I was supposed to use the overload that specifies an IFormatProvider, so for most of my code, I used ToString(CultureInfo.InvariantCulture), and now in VS 2005 Beta 1, I am getting warnings:

    Warning 3  'System.Enum.ToString(System.IFormatProvider)' is obsolete: 'The provider argument is not used. Please use ToString().' C:\. . .\Visual Studio\Projects\. . File.cs 617 64   

    I thought it was a pain to specify CultureInfo.InvariantCulture for every call, but I went along with it.  I guess the MS people decided to agree with me.  :-)

    I'm actually glad about this change.  Seems like most v2.0 changes are for the better. . . . but I still take issue with not having a concrete assembly in web site projects - we need a way to configure what the dynamically compiled assembly will be called.


     

  • You can see and submit bugs logged against VS 2005 Beta 1 - level 200

    I invite you to visit the VS 2005 Beta 1 Developer Center.  You can submit suggestions and bugs to the VS 2005 team.  I've submitted several bugs already and made a suggestion.  Two of my bugs have been validated, and another was a duplicate.  Hopefully my bugs will be fixed in the Beta 2.  Either way, I've done MY part to ensure that the IDE I USE is the best it can be. 
  • Extending web.config with your custom configuration sections - level 300

    The web.config file in ASP.NET enables configuration of the entire ASP.NET application.  It is a file that is part of just about every ASP.NET application, yet I see many developer who roll their own configuration schemes beside the web.config file instead of making use of the functionality already built in.  Yes, some may use the appSettings section and then just retrieve a value from a key, but web.config can do so much more than that!  Here is a sample of how easy it is to add your own configuration section, thereby partitioning a section of configuration items away from the others:

    <configuration>
    
    <configSections>
    <sectionGroup name="MyCompany.MyApp.MyNamespace">
    <section name="SomeClassesConfig"
    type=“MyCompany.MyApp.MyConfigHandler“,MyCompany.MyApp" />
    </sectionGroup>
    </configSections>
    <MyCompany.MyApp.MyNamespace>
    <SomeClassesConfig>
    <add key="myKey" value="myValue" />
    </SomeClassesConfig>
    </MyCompany.MyApp.MyNamespace>
    </configuration>

    Then, in your code, you just have a class, MyCompany.MyApp.MyConfigHandler that inherits from System.Configuration.NameValueSectionHandler, and that's all it takes.  If you don't make your own ConfigHandler, then you have to specify the strong name in your type=”” attribute, and not only is that painful, but when you migrate this code to .Net 2.0 and beyond, you will have to modify every place where you gave a strong name.  If you make a superclass of it, then when you migrate the superclass, you're golden.

    To get to these values in your code, you just use a NameValueCollection that you can get from calling:

    ConfigurationSettings.GetConfig("MyCompany.MyApp.MyNamespace/SomeClassesConfig");

    Does that look like an XPath expression to you?

    You can further extend the web.config file with your own ConfigHandler that has nested XML elements instead of just a key and a value.  You could store complete object information in the web.config (if the data rarely changes).  Remember that every change of the web.config forces a restart on that directory and its children.

    Coming up in May of next year, .Net 2.0 will have the APIs to modify .config files programmatically.  Check out the Beta 1 to use this functionality right now.

  • Successfully using Server 2k3 on my development laptop - level 100

    Two months ago, I blogged about installing Server 2k3 on my development laptop.  I'm following up with that post to say that everything has gone just fine.  Every XP driver worked perfectly on my Dell Lattitude D600.  Everything has been perfect.  Very stable, very fast, and I can profile my applications and have confidence that the results will be better than if I profiled them on an XP box.  Besides.  XP .Net CLR 1.1 has a bug in the Large Object Heap that throws stuff off. 

    I can now recommend using Server 2k3 as a development platform for web applications.

  • Obvious compatibility bug in .Net 2.0 Beta 1 - your v1.1 code won't work - level 100

    This post is to share a backwards compatibility bug in v2.0 Beta 1.  I ran into this bug when porting a project of mine.  This wasn't the only issue, but here it is.  Run this page under v1.1 and click the button to your heart's content:

    <%@ Page%>
    
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:Button id="Button1" runat="server" Text="Button" OnClick="Button1_Click"></asp:Button>
    </form>
    </body>
    </HTML>
    <script runat="server">
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Server.Transfer(Request.Path, true);
    }
    </script>

    Now, run this page under v2.0.  You will click the button, and your computer will never return the page.  It will lock up.  But really it's not.  Your computer is in an infinite loop.  This is because the second parameter of Server.Transfer has been changed. 

    • When set to true, in v1.1, the querystring would be preserved.
    • In v2.0, the form values are preserved as well.
    • Because the button element is a form element, the button submit is transfered also, so the page thinks that every run is a postback, so the page keeps Server.Transfer()ing back to itself until you kill it.

    It's nice that Microsoft added functionality, but we really just need another overload.  Leave the method like v1.1 because this broke my project, so I'm sure it will break some other projects.  Add an overload to accept a third parameter as a boolean which dictates whether to preserve the form values:

    Server.Transfer(Request.Path, true, false);

    I would use the above so that my querystring would be preserved but the form values would not.


  • using VS 2005 Beta 1 and Yukon Beta on the same machine - level 100

    Tim Sneath posted a great piece of information today.  I ran into this issue exactly:

    I installed Whidbey and then Yukon.  Yukon setup kept complaining that there was already a conflicting version of Yukon on the box (I had MSDE Express), but that wasn't it.  Tim points out that Yukon has a slightly new version of the .Net framework, so what I need to do is uninstall v2.0 (not VS), and then Yukon will install fine.  Great job Tim.  I was stumped.

    By the way, I saw a demo of stored procedures in .Net languages, and I'd like to clear up something:

    In Yukon, there is no way to get or modify data without using TSQL.  Yes, stored procedures can be written in any .Net language, but stored procedures are just executable bits of logic.  Manipulating rowsets in the database still requires TSQL calls, but any calculations, validation, etc can be coded in the .Net language.  That being said, is there a reason to code stored procedures in .Net?  Not for me (yet).  I make it a habit NOT to write logic in my Sprocs.  I manipulate data rowsets, and that's it, so if I have to use TSQL to manipulate rowsets, then I'm right where I am now.

    Also, what about the issue of database migration, or switching databases.  If you write database sprocs in .Net, you can never switch databases.  What if you develop a product with Yukon.  You'll never be able to implement it with SQL Server 2000, and 2000 will be around for a long, long time because it suits the needs of so many businesses.

    I'm probably coming across as a pessimist, but that's not my intent.  I just know it's inevitable that somebody will devleop an entire application on Yukon's CLR and then wonder why their database box is so damn slow.  At least, it'll be good material for The Daily WTF.

  • Attending the InfoPath/ASP.NET 2.0 MSDN event in Austin, TX - level 100

    David Waddleton, and MSDN representative, is giving an MSDN event on InfoPath and ASP.NET 2.0 at the Gateway theater in Austin, TX.  InfoPath is quite interesting as an application client.  Currently my application client is a browser since I write ASP.NET apps, but if all the users have InfoPath on their computer, that can be the client.  Now, it's a no-brainer for web apps because they can use any browser as the client, but I'm not sure that InfoPath would be viable for my use even though I work for a very large enterprise company.  I can see that a consulting company might be able to use it by building it into the minimum system requirements of their solution, but for my large company, I would have to sell the top IT big dogs on the idea of installing InfoPath on every workstation.  That's a lot of licensing costs that are not present with web apps or even a click-once app.  Maybe in time it will look like a better option for me.

    Just an overview of what I'm doing:

    I have my laptop here running on battery power, and I'm connected to the Internet through a USB cable attached to my Sprint phone.  Very nice setup.  I can get on the Net anywhere I can get signal, and I really don't go out into west Texas much.  I live out in the country, but Sprint has pretty good coverage even outside suburbs.

  • Yes, sometimes: 好文章分享 -- 午睡的神奇力量 - level 100

    In response to the blog post: ?????????? , I agree with some of the stuff that was said.  If you are feeling tired, sometimes you have to take a break and get some coffee or tea - I got a Chinese coworker to translate for me :^), but I'm curious as to why http://weblogs.asp.net has chinese posts on it.  Maybe if you post in a different language, include a link to a site where that post can be translated into English.
More Posts Next page »

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

Headspring Systems

View Jeffrey Palermo's profile on LinkedIn

See my new blog at .jeffreypalermo.com