.NET

What would NHibernate ICriteria look like in .net 3.5?

If NHibernate decided to ditch compatibility with plain old .net 2.0 and focus on 3.5 how would the ICriteria interface change? Previously I was throwing around an idea of using a simple lambda expression to resolve the property name. Well, I couldn't help but build on this a little more. The following idea is not supposed to be LINQ, that would be far more complicated and LINQ is essentially its own interface, which is not the point. The point is, if ICriteria was written today in .net 3.5, what could it look like? How could it change? So just to recap,...

posted @ Sunday, August 17, 2008 3:12 PM | Feedback (0)

NHibernate Type Safety using Lambda Expressions

I can't remember if this has been around before, I do vaguely remember seeing something like it. However, I just wanted to apply a snippet of code I found on Paul's blog the other day to NHibernate. Of course we will definitely have type safety in queries when Linq-to-NHibernate is completed. But surely linq-to-nhibernate is not going to be the _only_ way of writing queries. Using the original code snippet 'as is' would look something like this: ICriteria c = session.CreateCriteria(typeof(Person));c.Add(Restrictions.Eq(Property.GetFor(() => new Person().FirstName), "John")); This is ok, but a little long winded, so I implemented another class called RestrictBy which can break...

posted @ Tuesday, July 22, 2008 7:38 AM | Feedback (3)

NHibernate Compatible Shared Hosts

NHibernate is a remarkable ORM, however with all the magic comes a few caveats, these being the difficulties running NHibernate apps in a shared hosting environment. I'm still convinced that it's entirely possible, so I've decided to start compiling a list of success and failures that others (and myself) have had in getting things working. Compatible Shared Hosts Host Name Comment ...

posted @ Friday, March 28, 2008 11:21 PM | Feedback (0)

IDataErrorInfo for ASP.NET

As far as I'm aware ASP.NET doesn't support IDataErrorInfo, I've asked about this in many places, including Tech.Ed '07 with no success. The closest things I've seen in terms of Business Object level validation is from Enterprise Library validation block (which is attribute based and can render out with custom EntLib web controls) and another example in the Futures Dynamic Data Controls using Linq (I have no idea how this magic validation magically appears). It all just seems overly complicated, so, have a look at the IDataErrorInfo interface the methods are: string this [ string columnName ] { get; } string Error { get; } Simple and...

posted @ Thursday, November 08, 2007 11:42 PM | Feedback (2)

Another SubText Blog

Yes, I'm one of the crowd now, all because my old host Jumba is turning off the last of their Windows boxes, and coincidentally, the one I was hosted on. This has happened previously when they shut down some legacy Windows servers and forced everyone on it to upgrade. Since Jumba is now no longer offering HELM windows hosting they have recommended xHostSolutions who have pretty comparative deals to what I was previously on, only better. This now gives me access to an MS Sql Server database, so I thought I'd take the opportunity to install SubText. I still think that Single User Blog is a...

posted @ Saturday, June 09, 2007 9:14 PM | Feedback (2)

ERROR: 42601: a column definition list is only allowed for functions returning record

Since the postgres forums appear to be a little quite, I'll post my error here as well.  This error is in regards to the postgres .net npgsql driver and seemed to only occur when using stored procs. The Error The behavior I experienced happens when using stored procedures started out with me getting the following error: ERROR: 42601: a column definition list is only allowed for functions returning "record" After checking and double checking the stored proc and the parameters I was sending in I turned Npgsql's debugging on. The error appears to be coming from a statement that looks like the following: select * from...

posted @ Thursday, March 15, 2007 9:30 PM | Feedback (0)

The C# @ String Literal

C# is a pretty sweet language, and there are many, many, many little things that just make the code that much nicer. Have you ever been in a situation where for some reason you NEEDED to have a string/code fragment/js fragment/sql statement inline in your code because you don't believe in resource files or stored procedures? Aside from whatever great debate about "if you should or shouldn't". If you are going to, please, please, learn to take advantage of what C# has to offer, yes I'm talking about the '@' string literal. Now I'm not going to target anyone in particular,...

posted @ Tuesday, March 06, 2007 1:10 AM | Feedback (4)

A Free, FreeTextBox Alternative

I don't know why but FreeTextBox has just never cut it for me. It's wonderful and easy to install and it comes as a nice control in a .NET assembly. But it doesn't give you the nicest HTML back, in fact I'd go as far as to say, it mutates GOOD HTML you put in there yourself, this is bad. Luckily there are some other free alternatives such as TinyMCE, which is a nice little editor. The only catch is it's pure javascript and requires a little manual intervention to work with your serverside code. On a...

posted @ Wednesday, February 21, 2007 9:57 AM | Feedback (6)

Hello IronPython for ASP.NET

Although this is not new news (released November 2006 I think), I'd like to point out how cool having Python run ASP.NET is.  I don't actually know how to program python...yet...but programming Python appears intuitive be nature.  To get an HelloWorld IronPython ASP.NET application running, it took me all of about 5 minutes, 3 to download and install the add-in, 1 to open Visual Studio, then another minute to type in some stuff and run it.  Sweet.  At this point the intellisense has nothing of your other standard languages like C#, but I'm sure that's coming. One of the biggest issues...

posted @ Sunday, February 04, 2007 9:14 PM | Feedback (0)

ASP.NET 2.0 Mozilla Browser Detection Hole

It has recently come to my attention that there is something drastically wrong with the way search engines have been indexing my ASP.NET 2.0 blog. As I've started to explain previously, this is because of the way the browser detection is set up. To give a brief rundown ASP.NET 2.0 has a default browser definition which seems to assume that the default browser is fairly capable and supports common things such as javascript and cookies. A browser definition can get inherited into other definitions which can then override specific properties to update it for that specific browser or browser version. Apparently in...

posted @ Monday, December 11, 2006 12:58 PM | Feedback (11)

Cleaning Up ASP.NET Sessions in Google

ASP.NET and Dirty Urls There are two things that have been bothering me about pages that are getting indexed in Google from an ASP.NET application. The first is somehow there are ASP.NET Session Urls ending up in the Google index. This is bad because searchers that actually do click these links are likely to get a 500 error (internal server error) because they will be trying to access a page of an expired session. How is Google finding all these 'bad' urls? Well apparently there is no browser definition in ASP.NET 2.0 for the Googlebot's useragent string, so when the spider...

posted @ Wednesday, December 06, 2006 11:49 PM | Feedback (3)

Brendan's C# Modifier Keyword Guide

After a little bit of thought from my last post I decided to write a small sample class and use tooltips to document what some of the most common modifiers do. So run your mouse over the boxes below to see the documentation about the keyword. Edit: In an effort to unbreak my RSS I've moved it to it's own page http://www.kowitz.net/CSharp_Modifier_Keyword_Guide.aspx

posted @ Sunday, November 05, 2006 11:54 AM | Feedback (0)

The public new overridden int ID

As with most days I learn things about programming and C# that I didn't know before, until I've already past the point where I know I'll never ever come close knowing everything. Now, I though I knew a bit about method/property modifiers, well apparently not, found one today that I haven't seen before. Unexpected places to find 'new':Maybe I've been living under a rock for quiet some time, but I'm talking about the keyword 'new'. And I bet the first this that's come to mind is 'what kind of developer are you? everyone knows about 'new'! Well it...

posted @ Tuesday, October 31, 2006 12:45 PM | Feedback (0)

ASP.NET Mobile Content

A few weeks ago before everything started getting really busy both personally and work wise, I still somehow found the time to put together a mobile version of my blog content. Device DetectionIn the beginning I was just using the ASP.NET property Request.Browser.IsMobileDevice for device detection, but for some reason WindowsCE is not considered a mobile device by this property, so I included an additional 'if Request.Browser.Platform.Equals("WinCE")'. The mobile devices request will be redirected to www.kowitz.net/mobile/ which displays only one post on the screen at a time using 100% mobile controls and pages. While I was creating my Mobile...

posted @ Friday, October 27, 2006 6:31 AM | Feedback (0)

Url Rewriting using IHttpModule vs ISAPI Rewrite

Why not use IHttpHandler for rewriting: You can find the previous post I've done on this subject here, it has a c# source code example and will also explain some of the downfalls of using the IhttpHandler for rewriting.  In summary my basic feeling on this is IhttpHandler is great if you know the Url that is going to be requested eg. /Rss.ashx every time an rss reader requests this Url, the reader will never know that Rss.ashx doesn't necessarily have to exist as the response is picked up and written back by the handler. How is IHttpModule more useful url rewriting? When it...

posted @ Friday, September 15, 2006 7:25 AM | Feedback (7)

Trackback Spam, meet Akismet

Just recently I have been getting bombed with more trackback spam then I'd like. SUB has some built in protection for this by scanning the incoming exert for a link to the current post. The initial problem with this approach (as Al explained to me) is that other blogs such as wordpress will only submit the first X number of characters if its a long post, meaning that a link back to my post may not be in there and the trackback will fail. That aside, in my case nothing was never going to work even for ham, this...

posted @ Sunday, August 13, 2006 5:57 AM | Feedback (1)

Accessing controls on a masterpage

Here are a couple of neat things in ASP.NET 2.0 that I've used recently. Access the controls on a master page. You'd think it must be possible, and it is, it's easy to do.Label Label1 = (Label)Master.FindControl("Label1"); Label1.Text = "Set by child page"; ObjectDataSource...Before I used it I was suspecting that it may have been like one of the adapters in 1.1 which I try to keep away from on a the page itself. I find it cleaner to put all the database access logic in a datalayer under the business objects. Well it seems Microsoft may have been thinking...

posted @ Wednesday, August 02, 2006 9:31 PM | Feedback (1)

ParaSoft .TEST Test Drive

Intro Over the last few months we have been attempting to implement some 'better' best practice methodologies within our SDLC. Some of the things that we have already been addressing are: Simple Coding Standards and Rules Nant Build Scripts Continuous Integration with the help of Cruise control Although I feel this is a good start, one of the more critical best practice aspect that has not been properly addressed is Unit and Regression testing. At the beginning of the previous project we had good intentions but because we got extremely battered for time, the Unit tests were all but abandond. However, the time has come...

posted @ Sunday, July 02, 2006 11:14 PM | Feedback (0)

Programming Visual CSharp 2005

Programming visual C# 2005: The Language by Donis Marshall Book highlights for me:Below is a brief list of some of the language highlights presented in "Programming Visual C# 2005" that I have finally been able to get my hands on.Nullable types//Define a nullable type int? a = null; //Boxing a nullable type object b = (object)a; //Detecting if a boxed value is a nullable typeif(b.GetType().IsGenericType && b.GetType.GetGenericTypeDefinition() == typeof(Nullable<>)) //Avoiding nulla.GetValueOrDefault(0); //Setting a default value a = value ?? 0;Weak references//Using weak reference is a way of pointing to an object's value, but it's special because when our friend the garbage...

posted @ Wednesday, June 14, 2006 3:54 AM | Feedback (0)

TrekXP, A Concept and Initial Idea

Foreword: Below is a description of a bug tracking and project management concept that I think would help handle business driven development for an internal software development unit. It is understandable that IT will of course be needed to make recommendations (forceful decisions in some cases) over what needs to be developed next, however in general the overall product should mainly be driven by the user's highest priorities and desired features. Description: There seems to be a lot of bug tracking software out there, however, I'm struggling to find an extensible package that properly incorporates some kind of XP model. TrekXP is an...

posted @ Wednesday, June 07, 2006 11:51 AM | Feedback (0)

Online Presence Webpart

You may have noticed that over the past few weeks I have been trying to build more interactive elements into this blog, some of these include. Most viewed posts webpart. Rate a post. Highest Rated posts webpart. Concurrent user indicator. MSN client, online / offline status. Sessions per hour graph. My intention was that this blog would start to expose more of the interesting content and create a slight online presence awareness by subtly reacting to...

posted @ Saturday, May 27, 2006 7:30 AM | Feedback (2)

Your Blog has signed-in

Today I was browsing the website ProgrammableWeb, which lists the Web APIs by a lot of well known sites. One of the things that caught my eye was MSN, and then I noticed they had a listing for Messenger. After clicking details I soon found it was only a description of how Javascript can invoke a chat window from the installed messenger client. I wanted to take this idea further and maybe integrate something Messengery into SUB. After a single search I come across DotMSN, a C# library for Messenger. So& as an experiment I've integrated the library into SUB....

posted @ Sunday, May 21, 2006 9:20 AM | Feedback (3)

Removing ASP.NET Calendar Control's Default Style

This problem has been bugging me ever since we hit it the other day at work. It occurred when Al was trying to style a .NET Calendar using an external CSS file. In the properties of the Calendar you can specify the css class using the CssClass fields, these render correctly. However, there are a few properties such as DayStyle which have a default colour that renders in the ‘Style’ tag of the link. If the ForeColor is specified it does render that colour, if you don’t specify, it renders ‘black’. This effectively makes the CssClass field useless for setting...

posted @ Saturday, May 13, 2006 2:03 AM | Feedback (6)

New webparts, SUB Monthly Archive List

I've had a couple of experimental things going on here in this blog. Firstly is the Archive page, it now renders the archive list in a similar fashion to a plug-in Al has created for wordpress. As for the whole query problem with the wordpress version, the SUB version of this does exactly 1 query for each month listed or 0 queries if that month has already been cached. The other experimental webpart I've been running is the "Popular Posts" component (displayed on the left). Everytime a post is hit it increments the daily count, then it selects the...

posted @ Monday, May 08, 2006 9:41 PM | Feedback (0)

Webparts without SqlExpress or SqlServer

One of the things that has been annoying me for some time about Webparts is that silly dependency on SqlExpress/SqlServer. My webhosting at Jumba comes with MySQL or something and not SqlServer. So up until this point to get around the dependency on SqlServer I simply disabled all the calls from SqlBlogPersonalizationProvider and that did the trick, but I had to manually do all the layout stuff and couldn’t use the webparts properly. A while ago when Microsoft released the source code for the old AccessPersonalizationProvider from Beta 1 I thought I’d come back and address this issue. Here’s what...

posted @ Monday, May 01, 2006 9:34 PM | Feedback (19)

.NET Stored Procs

One of the bigger features of SQL Server 2005 is it's integration with the .NET platform. Now there is the ability to write your stored procs with a language like C#. Now I'm just wondering how much of a good idea this is. Every scenario I try to go through still leads me to the same conclusion. This is, it may be handy for those really complex procedures that require some kind of funky processing or business logic or need to access the internet or a COM object or something. But for the most part, a loop is a loop,...

posted @ Monday, May 01, 2006 8:01 AM | Feedback (2)

CSharp and Datalayers

One thing that has become very important in my recent work is datalayers. I’ve seen a few difference approaches to filling objects after the data has been retrieved. All methods appear very similar in theory, but the implementations and restrictions are slightly different. I’ll start with the simplest example which is right here is “Single User Blog”. I like the theory behind this, basically there is a root object in the application that all other objects inherit from, in this case “ApplicationDataObject”. This root object contains a Fill() function which can in simplest terms, populate itself from an input datasource....

posted @ Tuesday, March 21, 2006 12:05 AM | Feedback (1)

'TextBox' cannot have children of type 'DataBoundLiteralControl'.

From what I've seen this particular error is already pretty well documented, however it is one of the things that Visual Studio is a little misleading about. Seems this is a lesson why you can't always rely on intellisense to tell you what to type. In a datagrid, the following code will error: Error: <EDITITEMTEMPLATE> <asp:TextBox id=TextBox1 runat="server"> <%# TimeZoneInformation.ToLocalShortDateString( (DateTime)DataBinder.Eval(Container.DataItem, "FromDate")) %></asp:TextBox> </EDITITEMTEMPLATE> This will land you with a "'TextBox' cannot have children of type 'DataBoundLiteralControl'." error. Solution.<EDITITEMTEMPLATE><asp:TextBox id="TextBox1" runat="server" value='<%# TimeZoneInformation.ToLocalShortDateString( (DateTime)DataBinder.Eval(Container.DataItem, "FromDate")) %>'> </asp:TextBox> </EditItemTemplate>In this case the "value" tag is valid, even though intellisense doesn't think...

posted @ Monday, March 13, 2006 5:14 AM | Feedback (12)

Update: Sqlite Dataprovider for SUBv2

Here is the new Sqlite Dataprovider for SingleUserBlog v2.0.1. It is now supports string IDs so any existing SingleUserBlog can migrate easily. Find out more information at its new home here. Please feel free to leave any comments, feedback or problems on this post.

posted @ Friday, March 10, 2006 11:45 AM | Feedback (1)

IHTTPModule vs IHTTPHandler

The proof of concept IHTTPModule friendly url rewriter for SUB using regular expressions. For my previous post regarding friendly urls see here.Edit: To read more on this topic see my next post here. There are very important differences between IHttpHandler and IHttpModule. Last week I was also playing around with IHTTPHandler as a way of implementing a stop-gap friendly url handler. Now the important difference is, once the request is sent to IHTTPHandler, if it doesn’t send any content back, the user will basically see a blank page. Now that’s not to say that one handler can’t pass the request only another handler...

posted @ Wednesday, March 08, 2006 6:43 AM | Feedback (3)

SQLite data provider for SingleUserBlog

Please be aware that it may still have bugs. I have been using it now for about two weeks, making small refinements as I’ve found them. To Install. Copy the “sub.db” file in the /Data directory. Ensure the “sub.db” file is writable and not read-only. Copy the "kowitz.SQLiteBlogDataProvider.dll" file into the /Bin directory. Copy the "System.Data.SQLite.dll" file to the /Bin directory. Change the config file so SUB now uses the SQLite provider: <DataAccessType> kowitz.SingleUserBlog.Services.DataReaderBlogDataProvider, kowitz.SQLiteBlogDataProvider </DataAccessType> If you experience any problems when using the provider, just post comments here. Download Get it here [Edit 10-Mar-06: Updated Link]View Source Files OnlineI've...

posted @ Saturday, March 04, 2006 9:54 PM | Feedback (12)

ASP.NET Google Sitemap

Probably the best thing about SUB is its simplicity. There are two things I’d like to try to document in this post, firstly is the code for adding a simple google sitemap, the other is actually a question. I’m still curios to why Darren has used hard coded URL formatting in most of the repeaters when displaying a collection of posts. Under the APP_Code/ directory there is a UrlFormatter class which can generate a URL for any ApplicationDataObject (post or feedback item). Taking this UrlFormatter class into consideration I have modifiied the GSiteMap.ashx file include a method that will write...

posted @ Wednesday, March 01, 2006 11:45 PM | Feedback (2)

Additions to SUB

Just downloaded and included the ASP.NET Google SiteMap control, had to modify it a little so it looks at the mainMenu="true" option. You can have a look at its output here.Also I've added a Post Archive, which just passes straight down to the sqlite datalayer where it groups posts by a formatted month/year string.The other addition so far is a new search control on the sidebar. It also passes straight down to the sqlite datalayer and returns the appropriate post records.

posted @ Monday, February 27, 2006 5:05 AM | Feedback (2)

Jumba, SingleUserBlog and nGallery

I signed up with Jumba a few weeks ago now, so I’ve been really trying to get at least SOMETHING onto this webspace. There were a couple of conditions on choosing Jumba…I want ASP.NET…well that’s about it. So the two things I currently have installed here are SingleUserBlog v2 and nGallery. I’ve played around with the SUB source code back in v1, and “apparently” v2 is heaps better. The changes I made to SUBv2 Well already I’ve written a new datalayer that uses the sqlite engine. What’s my reason for the sqlite datalayer? Well, I originally liked the idea of SUB...

posted @ Friday, February 24, 2006 10:53 PM | Feedback (0)

SingleUserBlogV2 Test

Just a test post after setting up SingleUserBlogV2, all my data is stored using a custom Sqlite dataprovider I wrote. Will explain it all later.

posted @ Thursday, February 23, 2006 9:36 PM | Feedback (0)

MS XML Parser

MS Released what looked to only be a partial implementation of their XMLparser with windows 2000, this was then finished by windows XP and a patchis floating around to update windows 2000. Now there is .NET, with its own built in XML parsing. I have been pulling data from a sql server, and then saving it out to XML. I then use the windows XML Parser to run it against an XSLT template to create my desired output file. Anyway .NET saves out a thing that looks like this: '&#xB ;' not exactly sure what it is yet, however...

posted @ Friday, May 20, 2005 1:38 PM | Feedback (0)

is mscorsvw.exe bad?

I've noticed an unusual process starting up after I installed Visual Studio .NET 2005 b2. mscorsvw.exe is .net 2.0's assembly optimizer. The good news is; it starts up and works away in the background optimizing .net assemblies for your pc. However I did notice, when installed on WindowsXP SP1 that has been upgraded to SP2 the mscorsvw.exe process starts up and claims an unbearable amount of CPU. It is apparently supposed to optimize in the background after it does your core assemblies which should apparently only take a few minutes. If it doesn't you've got a problem. My solution come coincidently...

posted @ Wednesday, May 11, 2005 1:05 PM | Feedback (3)