On this page.... RSS 2.0 | Atom 1.0 | CDF
# Tuesday, April 12, 2005

In case you haven't heard, the ASP.NET Team has done away with the proposed "code beside" model for ASP.NET.  I was recently forced to remember this when porting a Beta 1 demo to Beta 2 (well, more or less Beta 2, anyways).  I'm really glad of the change because it does indeed make moving 1.x to 2.0 much easier; it keeps a familiar programming model, and it addresses some of the annoyances of v1.x.

So I propose that we all forget that the term "code beside" was ever invented.  With the knights of the round table, let us say: "On second thought, let's not go to [CodeBeside].  It is a silly place."

Tuesday, April 12, 2005 3:06:19 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, April 8, 2005

I just ran into a problem that seems like it shouldn't be a problem, though I'm sure there's a perfectly obscure and valid reason it is.  Consider the following:

public class MyBase
{ // ...}

public class MyChild : MyBase
{ // ...}

public class Foo
{
  public static void Bar()
  {
    MyBase base = GetMyBaseFromSomewhere();
    MyChild child = (MyChild)base;
  }
}

The last line in Bar throws a System.InvalidCastException: Specified cast is not valid.  Why?  It seems to me that since we're guaranteed that MyChild has everything that MyBase has, it should become the child type lacking values only for the new fields that MyChild has defined.

I'm sure there's some completely reasonable computer sciency reason this doesn't work, such as the data is stored on the heap in a structure defined as MyBase that has no knowledge of MyChild, so it can't possibly know how to become MyChild; all the same, I think it should work.  If there is a way to work around this, I'd appreciate knowing about it.

Looks like this is another place where generics could certainly save the day.  We could specify GetMyBaseFromSomewhere<T>() where T: MyBase, new(), and then we could tell it (in the case above) that we want a MyChild instance.

Unfortunately, this app is in 1.1, so that's not an option.  As I see it, the only alternative here would be for me to define a new method like FillMyBaseFromSomewhere(MyBase base), pass a MyChild instance in, and have it populate the MyBase members on MyChild.  Or (worse), I could define a MergeFromBase method that manually copies the fields from MyBase to MyChild.  Am I missing other alternatives?  Maybe serializing as MyBase and deserializing as MyChild would work?  Anyone?

Friday, April 8, 2005 7:28:01 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [6]  | 
I was just pointed to this diagram of the ASP.NET 2 control lifecycle.  Not only is it immensely useful, it's pretty to boot!  I agree with him--every ASP.NET dev should be familiar with the control lifecycle.  It is of great help when debugging pages and designing advanced features.
Friday, April 8, 2005 1:58:24 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 

John Paul the Great

You all knew it was coming.  I simply have to say something about the passing of one of the greatest popes and men of our time.  It's tempting not to say anything just to avoid adding to the cacophony of voices talking about him (and popes in general), but since he had a personal impact on my life, I figure I should say something.

No, I'm not saying I ever met him.  When I say "personal impact," I mean that his writing was instrumental in my becoming Catholic, and I've grown fond of him over the years.  In particular, his encyclical (letter) Evangelium Vitae (The Gospel of Life) had a profound impact on my thought surrounding issues of life, specifically on the death penalty and artificial contraception.

Strangely enough, Evangelium Vitae doesn't go into the issue of artificial contraception in depth.  If I recall correctly, it really only talks about it in passing; however, it was the overall profound unity, simplicity, and depth of thought expressed by this great theologian and pastor that brought me (tentatively at first) to the other side of those two issues. 

For me, the issues of papal infallibility and artificial contraception were two key points that I had significant difficulty reconciling with in my journey towards the truth.  The former was an intellectual stumbling block; the latter held very real, practical consequences for me.

Needless to say, I've gotten past these issues.  And I'm glad of it because they were hindering me from moving on in my spiritual and intellectual journeys.  I also do believe, based on personal experience, that not practicing artificial contraception enhances the quality, longevity, and, dare I say, intimacy of marriage.  I suspect there are metaphysical implications that produce this effect, but there is also simply that you are forced to learn to know and respect each other and to patiently work with the physiological uniqueness that each person brings to the marriage.

Yet I digress...

I have nothing but admiration for the man.  On the one hand, he was criticized by ultra-conservatives (traditionalists, sede vacantists, SSPX, etc.) for being too liberal; on the other, he was criticized by the "liberals" (pro-abortion, pro-contraception, pro-womens' ordination, etc.) for being an iron-fisted dictator.  Some people even thought he was the anti-Christ.  Yet for all this, he patiently shepherded over one billion people and positively impacted many more. 

Some have said he played an integral role in the fall of communism.  He has taken great strides in rapprochement with the Eastern Orthodox, Jews, Protestants, Hindus, and even Muslims.  And in all of this he has remained true to the faith, which is a significant challenge in ecumenical and interreligious dialogue.

For myself, I felt a certain parallelism with him.  He was elected less than two months after my birth, so my life could be measured by his pontificate.  I don't know why, but that meant something.  Strange how we humans find significance in the smallest of things.  But the objective implication is that I have never known another pope, so it is strange for me to think of him as no longer leading the Church, even if I've only been a Catholic for a few years.  It's like you get to know someone you feel you've known your whole life just before they have to leave.

I can say that there is a touch of sadness I feel, yet I can't help but feel (honestly) happy for him.  As Archbishop Pell said, we are Christians--we believe that this is not the end.  I am also happy for him in that he can finally rest.  It was often hard seeing him, struggling to speak, walk, and even kneel due to his illness, especially when contrasted with the earlier video footage of him as a vibrant personality.  Yet despite all his illness and age, he was constantly on the go, constantly praying, writing, speaking, even singing, and visiting people all over the world.

In addition to his social activities, he has been truly prolific and profound in his writing.  I suspect that he will become a doctor of the Church due to his significant (and orthodox) contributions to our understanding of the faith.  I mentioned Evangelium Vitae, but there is so much more than that.  Not only has he written tomes of invaluable thought himself, he also sponsored and organized the new universal catechism, its revision, a few revisions to the missal, and much much more.

One could go on and on about the positive impact on almost every realm of human existence that he has had, and that is why I think he truly deserves the title of "magnus"--"the great."  Some men are called great because they waged many successful wars, as if killing is something to be praised, yet here is a man who is great because he spent his long life truly in the service of others, of goodness, of peace, and of life.

Requiem aeternam dona ei, Domine, et lux perpetua luceat ei.  Requiescat in pace. Amen.

Eternal rest grant unto him, Lord, and let light perpetual shine upon him.  May he rest in peace.  Amen.

Ora pro nobis, Ioannes Paulus Magnus.

Friday, April 8, 2005 12:47:50 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, April 7, 2005

I don't know about the rest of you (probably most of you aren't using custom attributes as much as I), but I find it a kludge to have to override a property definition just to override the attributes on that property.  If you think so, too, please add your voice to this suggestion for the next version of C#:

http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=b8ca2beb-c1c2-4002-b7f7-d2677d42c0fe

Thursday, April 7, 2005 9:48:25 AM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, April 6, 2005

It's not official quite yet, but you can go ahead and start learning ASP.NET 2.0 from the experts at the ASP.NET 2.0 Quickstarts site: http://beta.asp.net/QUICKSTART/aspnet/.

I've been told that they may be making tweaks between now and the official Beta 2 release, but don't let that stop you.  There's a lot of good content there!

Wednesday, April 6, 2005 11:44:56 PM (Eastern Daylight Time, UTC-04:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, March 31, 2005
Looks like Server 2003 SP1 went to RTM status recently (like yesterday).  As you can see in the list of Top 10 Reasons to install it, you really should seriously consider getting it ASAP for your 2003 servers.  There are some great security features they're adding. 
Thursday, March 31, 2005 10:01:09 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, March 30, 2005

I just had a strange bug pop up in this framework I've built.  It uses a number of custom attributes.  I have a base attribute and a corresponding collection.  On my collection, there's an Add method that checks to ensure the attribute hasn't already been added before adding, since ArrayList's default implementation is to allow duplicates and nulls.

I declared a type and applied a few of these attributes to different properties on the type, and yet, when I went to add them to my collection, I found that it was only adding the first attribute of a particular attribute type. 

So I looked up the docs on ArrayList.Contains to find out it uses Object.Equals in order to determine if the object is in the list.  So, on a hunch, I looked up System.Attribute, and sure enough, they override Object.Equals.  Here's a link to the help on that.  As you can see, it isn't very helpful.  It doesn't describe how it is changing the semantics of Object.Equals in any way.

So then it was time to pull out my trusty friend Reflector.  Looking at what Attribute.Equals is doing wasn't particularly helpful either because it keeps making external calls, but from what I can gather, it attempts to compare the values of all the fields on the two instances in question.  So you'd think, hey, this is a fair way to determine equality, right?

Wrong.  It doesn't work.  The two attributes I was having problems with had several differing values in their fields, yet this Equals method did not catch that.  Needless to say, this is obviously a bug.  I'd love to hear, in any case, the reasoning why Attribute overrides Equals and, in addition, why the help docs don't explain it one bit.

In the meantime, life goes on, and I had to figure out a separate implementation of Equals that'd work for my needs.  Unfortunately, as far as I can tell, there's no way to call the default Object.Equals method because, as you can see in Reflector, it will simply use objA == objB, which will only redirect you to the most overridden implementation. 

So since I couldn't compare references themselves, which is what I would prefer, I decided to just use two of my properties that were sufficient to meaningfully give the attributes separate identities. 

"Sure," you might say, "you should always do this."  But most of the time I don't see the point; it is often more confusing to do so because, apart from System.String, developers expect reference types to compare equality based on references not values, especially when dealing with custom domain types. 

So I'd say it's generally a bad idea to override Equals unless you really need to because, once you do that, you should also override GetHashCode and, at that point, you may as well just toss the computer out the window and give all your money to charity.  It's just a lot of (usually) unnecessary work that can actually cause confusion and introduce unexpected bugs into your apps.

Anyways, to bring this to a close, if anyone can explain the rationale behind what Attribute is doing, I'd appreciate it.  And if any MS BCL or corlib guys read this, please update the docs on Attribute.Equals to be more meaningful.

Wednesday, March 30, 2005 3:35:39 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, March 29, 2005

http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?FeedbackId=dd8d277a-89b8-4e80-9e65-bac1c5279f55

To summarize, I'm being told that having the component designer break every time you double-click on a class that inherits from an abstract class is okay.  The absurdity of it is overwhelming.  Just show me the code! :)

Tuesday, March 29, 2005 9:24:51 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, March 17, 2005

It's nice when a patently Catholic holiday makes it into most secular calendars, even if it's just so that the retailers can sell green stuff and Guiness can make a few extra $$.  As fun as this day can be, let's not forget about the origination of this feast.

Here's a great article on St. Patrick. To sum up, St. Patrick was an early, perhaps the first, Catholic missionary to Ireland, circa 500 AD.  There have been many legends that have grown up around him, but suffice it to say that he took the route that made the most sense in societies in the early middle ages, i.e., to convert the political leaders, because, in those days, religion was a matter of state; if you convert the leaders, you convert the society. 

St. Patrick was successful in this, so he is credited with converting Ireland to Catholicism and has so been named the apostle and patron of Ireland.  For a variety of reasons, Ireland and the Irish, have retained a very strong Catholic identity despite (or perhaps because of) the several attempts by the English to convert and suppress them to one or other flavor of Protestantism.

The Irish brought the holiday of their primary saint and their distinct Catholic cultural identity with them over to the U.S. and the rest, as they say, is history.  So wear some green, go out and have a pint, and think about St. Patrick and how amazing it is that one person can have such a great impact on humanity.

Thursday, March 17, 2005 7:34:56 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 

In a previous blog, I discussed the difficulties I had in getting activity tracking to work for dasBlog, which ultimately boiled down to the fact that threads in the ThreadPool (which dasBlog uses for logging activity) do not share the impersonated identity of a web application. 

The easy solution, if your hoster will allow it, is to call them up and say, "hey, give ASP.NET's default process identity Modify permissions on the logs directory."  However, if your hosting provider won't do that or if you prefer not to do that yourself, you have another option.

This article, on ASPAlliance.com, describes the steps you can take to get ThreadPool threads to use your impersonated identity.  It describes how to set up application-wide impersonation like your hoster might do it and then shows how to deal with it.  I included a helper class for use with this scenario that can be found as a download on the last page.

If you have any comments or suggestions to make it better, feel free to share!

(Omar has agreed to include this in a future build of dasBlog if I work it into the project for him, so if you'd like this feature let me know.)

Thursday, March 17, 2005 7:11:05 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  | 
# Thursday, March 10, 2005

I've been asked numerous times what “dotNetTemplar” is and/or do I know the history of the Knights Templar.  The answer to the latter is yes, probably a little better than most, as it falls within one of my areas of expertise.  And I did, in fact, choose dotNetTemplar with the Knights Templar in mind, as the Latin motto and icon on this site might suggest.

For those of you who don't know, the Knights Templar were the first military order, founded during the time of the Crusades.  For a brief overview, you can read this article.  The primary reason the order appeals to me is that they were the first group to successfully blend a patently secular occupation (soldiering) with a religious vocation.  Their motto, “not to us, Lord, not to us, but to your name give glory,” is what I think all of us who strive for excellence in this world should have as our motto.

So I adopted their motto as my own.  I, too, work in a secular occupation, and I try to do my best at it.  Yet I am a man of faith and believe that all the good that we have--our talents, belongings, intelligence, strength, etc.--is a gift from God.  I believe that without God, the source of all being, I would be and do nothing, so everything good that I am and do is thanks to God; therefore, he deserves to be honored for it.

Hence I try in my life (though I'm not by any stretch of the imagination perfect at it) to blend my faith into my secular activities, whether it be through keeping reminders of my faith near me, sharing my faith with others as seems appropriate, or simply doing what's right as much as I can by, for example, not pirating software, not lying, not cheating, giving to the homeless guy on the street who asks for money regardless of what I think he'll do with it, etc.  And by working towards this blend, I hope to in some ways--ways that I truly hope are not ostentatious--glorify God in my everyday life.

Non nobis, Domine, non nobis, sed nomini Tuo da gloriam.

+dotNetTemplar+

Thursday, March 10, 2005 9:27:36 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [3]  | 

I was just talking (writing, actually) to some buddies about why we can't have multiple inheritance.  James Avery pointed me to this blog by Wesner Moise, discussing the complications and potential perf hits we could take with MI.  He says that Eiffel's done it using the compiler so that you can have default implementations for interface methods that get emitted where (I presume) you don't implement it yourself.

Truly, I don't care what we call it.  I just would like the convenience of being able to have default implementations of methods that can be shared among multiple types and can be overridden.  If you want to call it default implementations for interface, multiple inheritance, mix-ins, or whatever, I really could care less as long as I don't have to copy and paste the same code over and over (or maintain all those copies) or write calls to helper methods (and write the corresponding helper types and methods).

I also don't particularly care if it is two or three levels of indirection to make the call.  That's really getting a bit overly concerned with performance; developer time, my time, is far more important than a few clicks on the processor, even multiplied a novemdecillion times.  We can upgrade and scale out relatively cheaply, but we only have so much quality developer time.

Thursday, March 10, 2005 3:32:52 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 

Thanks to Server Intellect!  Ever since I put dotNetTemplar.Net up, I've just kind of tolerated that my activity tracking doesn't work.  It was one of those things where you just don't feel like hassling with figuring it out.  dasBlog was sooo easy to set up, I wasn't about to complain or spend much time messing with it, especially since activity tracking is not too terribly important to me--it's just a nice to have.

Fast forward a few months.  I keep getting told by Cindy that she's getting referrals from me, so I finally get fed up and decide to figure it out.  First of all, I upgraded to the latest version of dasBlog, thinking maybe there was a fix in the upgrade.  Not so, but I did get some nice perf enhancements and a CAPTCHA comment spam blocker (and yes, I know these aren't perfect, but they're better than nothing).  And I'm now getting emails for referrals as well.

So my next step, as any good developer will tell you, was Google.  Searching on "tracking not working dasblog" didn't turn up much.  I tried a few variations and found some blogs by folks talking about dasBlog and/or tracking, but nothing along the lines of what I was looking for.

Then I decided to log into the kickin' control panel for my Server Intellect hosting, thinking it might be some setting (probably permissions) that I could change.  Well, I found out I can't do everything in the control panel (i.e., change permissions on directories), but I did find out that the logs directory only had files from 11/21/2004-11/26/2004.  Bringing up those dates in my activity tracker actually showed data (wow!), so I then was almost sure it was a permissions thing. 

Since I can't change/check that myself, I emailed Server Intellect at 6:11am, asking them to check the permissions.  The response, which I received just about an hour later (I guess for once I'm up earlier than someone), was that dasBlog does logging under ThreadPool threads and that my site runs under impersonation.  The configured site impersonated identity has the requisite permissions to write to the logs directory (and the SiteConfig and content--hence most of dasBlog works); however, the ThreadPool doesn't inherit the identity of the impersonated user, so the logging threads couldn't write to the logs directory.  They granted the ThreadPool's identity those perms on the logging directory, and voila, I'm actually seeing activity tracking data again!

Of course, now knowing the problem, a Google search on "ThreadPool thread doesn't inherit the impersonation settings" brings up a blog by Omar Shahine that shows this isn't the first time Server Intellect (formerly EAServe) has run into this problem.  I guess they need to add a "are you running dasBlog" checkbox to their signup form so they know to enable this or perhaps add it to their KB.  I'm not complaining, though--as soon as I reported the problem, it was fixed. 

So thanks again, Server Intellect!  Now maybe I can figure out a way to get the ThreadPool to inherit the identity of the queuing thread without having to know the logon info for that identity...

Thursday, March 10, 2005 7:55:08 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  | 

Disclaimer
The opinions expressed herein are solely my own personal opinions, founded or unfounded, rational or not, and you can quote me on that.

Thanks to the good folks at dasBlog!

Copyright © 2019 J. Ambrose Little