ASP.NET 2.0 Page Life-cycle#

ASP.NET 2.0 has a added a bunch of extra spots in the page lifecycle for programmers to insert their logic.

The guys over at www.csharper.net have put together a great list of these events and some notes about them in applicable.

You can see the article here, or you can click through to my full article where I copied their table.

Categories: Programming | .Net | ASP.Net | Architecture
Sunday, April 30, 2006 10:13:38 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Grant Execute Rights To All SPs#

Many times you can have a database that has access to it restricted to SPs.  If the database is application specific, then there is a good chance that 1 user account will need to access all these SPs to run the application.

My friend Phil found and updated this script to run in SQL Server 2005 to generate the necessary code to grant execute rights to all SPs in a database for a given user.

SELECT 'GRANT EXECUTE ON ' + sysobjects.name + ' TO AccountName' + 

CHAR(10) + CHAR(13) + CHAR(10) + CHAR(13) 

FROM sysobjects 

WHERE type = 'P' and category = 0 AND name not like 'sp_%'

 

Categories: Database | SQL Server | T-Sql
Thursday, April 27, 2006 6:54:32 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

SQL Server Query Results To Excel#

There are many times when I just want to run a query and send the results to someone in an excel spreadsheet.

You can easliy copy the and past the results, but you don't get column headers, and you lose formatting in many cases.

Dinakar Nethi has a good article about how to directly import the results of a query into excel.

I just used his method and it worked great.

Categories: Database | SQL Server
Thursday, April 27, 2006 2:51:33 PM (Central Daylight Time, UTC-05:00) #    Comments [3]  | 

 

Secret Message#

I think this is pretty cool.

Check out the image below.  Then use the link below to open up just the image in a new browser window.

Resize the image (make it smaller) to see the secret message.

 




secret.gif (139.54 KB)

 

Categories: Cool | Interesting | Misc
Thursday, April 27, 2006 10:34:20 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS2005 VB.Net Create Properties From Private Fields#

"Refactor!" has the ability to turn your fields into public accessible properties, but it kinda sucks because 1) you have to do it 1 at a time, and 2) the naming convetion is all wrong. 

For example if you have a private integer called myInt then your property will be MyInt1.  Not exaclty what I am looking for.

So I updated my 2002 macro for creating these properties.  It should allow you to follow a variety of naming conventions "m_XXX", "ciXXX", "strXXX" etc.

Just include the macro below, then just highlight your private fields, and run the macro.

   ' highlight the private properties
Public Sub AddClassProperties()

Dim oTextSelection As TextSelection = DTE.ActiveWindow.Selection
Dim iLinesSelected = oTextSelection.TextRanges.Count
Dim colPropertyList As New Collection()
Dim iIndex As Integer
Dim oStart As EditPoint = oTextSelection.TopPoint.CreateEditPoint()
Dim oEnd As TextPoint = oTextSelection.BottomPoint

'Create an Undo context object so all the changes can be
'undone by CTRL+Z
Dim oUnDo As UndoContext = DTE.UndoContext

'Supress the User Interface. This will make it run faster
'and make all the changes appear once
DTE.SuppressUI = True

Try

oUnDo.Open("Comment Line")

Dim sProperty As String
Dim sLineOfText As String

Do While (oStart.LessThan(oEnd))

sLineOfText = oStart.GetText(oStart.LineLength).Trim
'*** do some kind of simple check to make sure that this line
'*** isn't blank and isn't some other kind of code or comment
If (sLineOfText.IndexOf(" As ") >= 0 And ( _
(sLineOfText.IndexOf("Public ") >= 0) Or _
(sLineOfText.IndexOf("Private ") >= 0) Or _
(sLineOfText.IndexOf("Dim ") >= 0) Or _
(sLineOfText.IndexOf("Protected ") >= 0) Or _
(sLineOfText.IndexOf("Friend ") >= 0) Or _
(sLineOfText.IndexOf("ReDim ") >= 0) Or _
(sLineOfText.IndexOf("Shared ") >= 0) Or _
(sLineOfText.IndexOf("Static ") >= 0) _
)) Then

sProperty = oStart.GetText(oStart.LineLength).Trim.Replace(" New ", " ").Replace("()", "")

colPropertyList.Add(sProperty)
End If

oStart.LineDown()
oStart.StartOfLine()

Loop

If colPropertyList.Count > 0 Then

For Each sProperty In colPropertyList
Call InsertProperty(sProperty)
Next

Else
MsgBox("You must select the class properties")
End If

Catch ex As System.Exception

Debug.WriteLine(ex)
If MsgBoxResult.Yes = MsgBox("Error: " & ex.ToString & vbCrLf & "Undo Changes?", MsgBoxStyle.YesNo) Then
oUnDo.SetAborted()
End If

Return
Finally

'If an error occured, then need to make sure that the undo context is cleaned up.
'Otherwise, the editor can be left in a perpetual undo context
If oUnDo.IsOpen Then
oUnDo.Close()
End If

DTE.SuppressUI = False
End Try


End Sub

Private Sub InsertProperty(ByVal sProp As String)
Dim oTextSelection As TextSelection = DTE.ActiveWindow.Selection
Dim sMember As String = sProp.Substring(sProp.IndexOf(" ")).Trim
Dim sDataType As String
Dim sName As String
Dim i As Integer
Dim iAscVal As Integer

i = sMember.IndexOf("(")
If Not i = -1 Then
sMember = sMember.Substring(0, i)
End If

i = sMember.IndexOf("=")
If Not i = -1 Then
sMember = sMember.Substring(0, i)
End If

sDataType = sMember.Substring(sMember.IndexOf(" As ") + 1)

For i = 0 To sMember.Length - 1
'iAscVal = Asc(Mid(sName, i, 1))
iAscVal = Asc(sMember.Chars(i))
If iAscVal > 64 And iAscVal < 91 Then
sName = sMember.Substring(i)
Exit For
End If
Next i

sName = sName.Substring(0, sName.IndexOf(" As ") + 1).Trim

If sName.Length = 0 Then
MsgBox("Unable to process the class property: " & sMember & ". This is usually caused by an incorrect naming convention (e.g. not cxName)")
Return
End If

sMember = sMember.Substring(0, sMember.Length - sDataType.Length).Trim

With oTextSelection
.MoveToPoint(.ActivePoint.CodeElement(vsCMElement.vsCMElementClass).GetEndPoint(vsCMPart.vsCMPartWhole))
.LineUp()
.EndOfLine()

.Text = "Public Property " & sName & "() " & sDataType
.NewLine()
.Text = "Return " & sMember
.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn, True)
.Copy()
.LineDown(False, 3)
DTE.ExecuteCommand("Edit.Paste")
.Text = "Me." & sMember & " = Value"
.LineDown(False, 2)
.NewLine(2)

End With

End Sub

 

 

Update1: When using code that you cut and paste from here, you might need to first paste it into Word or Wordpad.

Update2: When using this macro, you need a space (new line) between the last private field variable and your end of class line.

Categories: .Net | VB.Net | VS.Net | Tools
Thursday, April 27, 2006 9:53:16 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

450 Freeware Utilities#

This is a pretty good list of freeware utilities for all kinds of applications:

http://www.econsultant.com/i-want-freeware-utilities/index.html

 

Categories: Computers | Software | Tweaks | Windows | Utilities
Wednesday, April 26, 2006 9:25:22 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

applicationSettings, appSettings. app.config, web.config and userSettings#

I have seen lots of posts from people in the newsgroups trying to figure out what the deal is with the new config options in .net 2.0.

The main reason people run into problems is due to MS making a number of changes, including changes between the beta and the RC product, resulting in different answers based on how early you encountered the issues.

You can still do things the way you did with .Net 1.x.

       <appSettings>

              <add key="MyKeyName" value="somevalue"/>

       </appSettings>

and then you can access it with:

Dim myvalue As String = System.Configuration.ConfigurationSettings.AppSettings.Item("ConnectionString")

However, if you try this, VS.Net will warn you:

This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

It is important to note that the "!" above indicates that the fully quallified class listed, is located in the System.Configuration assembly, which of course you have to add to your project. 

So unlike previous versions, you need to manually add a reference to System.Configuration in order to make this new call.

Now, .net 2.0 and vs.net 2005 have teamed up to offer a new option for storing user settings which may seem more complicated at first if you don't know exactly what you are doing.  In the project properties you can select a "Settings" tab where you are able to modify application settings, which are in turn stored in app.config.  These settings can either be "User" settings, or "Application" settings. 

Application settings are stored in the app.config (or web.config), and are read-only.  User settings have a default value that is stored in the app.config, but your application can overwrite these default values as needed, and the users settings will be stored in:

%USERPROFILE%\Local Settings\Application Data\<Company Name>\<appdomainname>_<eid>_<hash>\<verison>\user.config. (non roaming)

OR:

%USERPROFILE%\Application Data\<Company Name>\<appdomainname>_<eid>_<hash>\<verison>\user.config (roaming)


The other nice feature of the 2.0 way of accessing these settings is that the settings are saved as a specific type from a wide collection of available types (String, System.DateTime, System.Drawing.Color, System.Guid, Bool, StringCollection etc) and when you access them from your code they are available in intellisense.

This may seem like it isn't important, but it means you can't mistype a setting key, or accidently try an invalid cast from one of your settings.  Also, storing a collection was a real pain in 1.x.    Now you can create a collection quickly and it will be added to the user settings like this:

   <setting name="MyCol" serializeAs="Xml">

        <value>

            <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xmlns:xsd="http://www.w3.org/2001/XMLSchema">

                <string>I am first</string>

                <string>second</string>

                <string>me third</string>

                <string>I am number four</string>

            </ArrayOfString>

        </value>

    </setting>

Pretty nice!

To access these properties you have 2 different ways depending on if you are using VB.Net or C#.

For VB.Net you use the "My" namespace and access it like this:

Dim mySetting As String = My.Settings.MySetting

For C# you access these settings through the "Properties" object

       string mySetting = Properties.Settings.Default.MyUserSetting;

That's it!

Categories: Programming | .Net | .Net Framework | C# | VB.Net
Wednesday, April 26, 2006 8:36:40 AM (Central Daylight Time, UTC-05:00) #    Comments [9]  | 

 

Virtual Server Networking With External Access#

I was having such a hard time getting MS Virtual Server setup so that my virtual servers could access the public network and vice versa.

In the end the problem was caused by a service that is running to enable my VPN connections.

The service is called:

Cisco Systems, Inc. VPN Service.

As soon as I turned off that service, everything with my virtual servers network worked just fine.

 

Categories: Interesting | Networking
Tuesday, April 25, 2006 3:54:49 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Composed vs Comprised#

I have no idea why I have such a hard time remembering composed vs comprised.

  • A car is composed of many parts
  • The parts compose the car.
  • A car comprises many parts

 

Categories: Misc
Tuesday, April 25, 2006 3:34:38 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Serialization / Deserialization of Objects With Version Changes#

CSLA as well as well as the proxy architecture I created for my last project, utilize serialization of objects to be passed across the wire, and deserialized on the other side into the same type of object.

This is different from passing datasets, which are then read into business objects.  We are actually passing the serialized version of the business object.

So what happens if you make a change to a business object such as adding a public property.  Will clients who have the old version of the Business Object be forced to upgrade? 

To see the answers along with some sample code for testing this out click on the link to read the full article.

So lets say you have a class that exposes 20 properties and 40 methods.  This business object is deployed on hundreds of clients computers.  When they send the BizObject over the wire, it is deserialized back into the exact same object on the server. 

But now, for whatever reason, you need to add 1 property to this BizObject.  For the current set of clients using this business object, you don't really need to deploy the updated change unless you have to in order to keep it from breaking.

So do you need to redeploy?  Probably not.

I serialzied a business object into a base64 encoded string and then added a public property to the object and tried to deserialize it with the "old" serialized string.  The result?  It worked.  The properties that had values when I first serialized it kept their values.  The fact that there were new properties didn't cause a problem.

How about going the other way: removing a public property that had a value when it was serialized, but doesn't exist with deserialized.  Again, this works. 

When doesn't it work?  When you are trying to deserialze into a different class, or a different namespace for the same class. 

So you can't serialize classA and deserialize it into classB, even if both expose the exact same signature.  The same goes for namespaces.  If you serialize classA, and then change it's namespace and try to deserialize it, you will get an exception.

You can try it out with the following code:

Imports WindowsApplication1.ASDF


Public Class Form1

Private Sub toString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdToString.Click
Dim o As New A
o.A11 = "this is a test"
o.Asdf1 = "another test"

Me.TextBox2.Text = EncodeBase64(o.CloneString)
MsgBox(EncodeBase64(o.CloneString))
End Sub

Private Sub fromString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles fromString.Click
Dim o As A = A.Hydrate(DecodeBase64(Me.TextBox1.Text))
MsgBox(o.A11)
MsgBox(o.Asdf1)
MsgBox(o.asdfdsa)
End Sub

Public Function EncodeBase64(ByVal input As String) As String
Dim strBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(input)
Return System.Convert.ToBase64String(strBytes)
End Function

Public Function DecodeBase64(ByVal input As String) As String
Return System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(input))
End Function

End Class


<Serializable()> _
Public Class Parent

Public Function CloneString() As String
Dim bFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim stream As New System.IO.MemoryStream()
bFormatter.Serialize(stream, Me)
stream.Flush()
stream.Position = 0
Dim bytes() As Byte = stream.ToArray()

Return System.Text.Encoding.Default.GetString(bytes)
End Function

Public Shared Function StringToStream(ByVal str As String) As System.IO.Stream
Return New System.IO.MemoryStream(System.Text.Encoding.Default.GetBytes(str))
End Function

End Class

<Serializable()> _
Public Class A
Inherits Parent

Private a1 As String
Private asdf As String
Public Property A11() As String
Get
Return a1
End Get
Set(ByVal value As String)
a1 = value
End Set
End Property

Public Property Asdf1() As String
Get
Return asdf
End Get
Set(ByVal value As String)
asdf = value
End Set
End Property
Public Function asdfdsa() As String
Return "Asdf"
End Function
Public Shared Function Hydrate(ByVal s As String) As A
Dim bFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim stream2 As System.IO.MemoryStream = StringToStream(s)
stream2.Flush()
stream2.Position = 0
Dim newClone As A
newClone = CType(bFormatter.Deserialize(stream2), A)
Return newClone
End Function

End Class


 

Categories: Programming | .Net | .Net Framework | Architecture
Sunday, April 23, 2006 7:35:24 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Rocky Lhota at CNUG#

I was able to get to the CNUG meeting where Rocky Lhotka was the feature speaker.

I had a chance to ask Rocky a couple of questions that had been bugging me about CSLA.

1)  He agreed that using the method of multiple result sets in datareader is not really a good idea in some instances, where a dataset would be much more useful.

2)  He suggested that you should usually not have an object that is sometimes a child and sometimes a parent.  I am not sure I agree with idea.  I believe I understand his point that if you are dealing with a Project object that has a collection of Employees assigned to it, you probably don't need the Employees to be as complex as if you were dealing with an Employee who is assigned to a bunch of Projects, but at the same time you are talking about writing 2 classes with 2 sets of data access scripts, vs 4 classes and 4 sets of data access.  But, he said that there are techniques for making a business object be both a parent and a child.  This is apparently detailed in Ch 7. 

Rocky suggested the book Object Thinking by Dave West

3) He mentioned that people have built UI Frameworks that run on top of CSLA.  I will have to look into this.

4) He was showing an example using an ASP.NET MultiView control, looked like a great way to enable multiple views of the same data.

5) I didn't get a chance to ask him about serialization and deserialization of classes that have small differences.  For example if you serialze an object and use the same byte array to deserialize a similar class, will it blow up if small changes are made, like you add a public property?  I will have to try this out myself.

In all, Rocky was a very good speaker.  Very engaging, funny, and on point. 

Oh and I won the raffle at the end, to get a copy of his book, the one I just paid 60 bucks for :-).

Categories: Programming | .Net | Architecture
Saturday, April 22, 2006 5:27:52 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Cool Icons#

A friend of mine has been using Plesk to automate some hosting settings.

I was taking a look at it and thought they had a lot of cool looking icons.

Not that anyone would want to download icons from a website and use them... :-)

Categories: Programming
Saturday, April 22, 2006 4:57:32 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Moving a Network#

This weekend I helped a client of mine move their computer system to a new factility.  In the new location I racked up and configured an HP Procurve switch, and 2 Cisco APs.

All in all the move went well.  I had some problems getting into the Procurve at first.  I think the problem was a bad serial cable, but in the end I got it working right.

We didn't quite have enough ports on Procurve, so I uplinked a couple of their old switches until I could procure some more modules for the HP.

The Cisco 1100 APs had great range.  I was able to blanket the entire facility with WIFI access.  Pretty nice!

Categories: Hardware | Networking | Firewall | Security
Saturday, April 22, 2006 4:55:42 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Fixing Left Column Problem With dasBlog Essence Theme#

I got a response back from Jelle Druyts regarding the problem where the left column falls off the page if you narrow the window enough.

He was kind enough to respond with his CSS changes:

/*----- Content Styles -----*/

#content {
        margin-top: 10px;
        position: relative;
        top: 0px;
}

#bodyContainer {
        margin-left: 220px;
}

/* Exceptions for Print */
@media print {
        #bodyContainer {
                width: 100%;
                margin-left: 0px;
        }
}

(...A little later...)

pre {
        overflow-x: scroll;
}

(...A little later...)

#metaContainer {
        border: 1px dashed #d0d0d0;
        background-color: #f0f0f0;
        color: #505050;
        font-size: smaller;
        width: 210px;
        position: absolute;
        top: 0px;
}

Once you apply these to the dasBlog.css file in the Essence theme package, the left column will remain in place!  Excellent!

Categories: Blogging | dasBlog | HTML
Saturday, April 22, 2006 4:28:59 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Delete the Web Apps DLLs and Everything Works#

Here is another of my favorite problems with VS2005.

If I have a Web Application Project.  If I build it (with no errors) then when I try to view it I get the error below.  However,

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The type 'Company.Web.Equipment.Global' is ambiguous: it could come from assembly 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\equipment\3f386648\c5a85b94\App_Code.gv_z5p7w.DLL' or from assembly 'C:\Data\Company\Company.Web.Equipment\bin\Company.Web.Equipment.DLL'. Please specify the assembly explicitly in the type name.

Source Error:

Line 1:  <%@ Application Inherits="Company.Web.Equipment.Global" Language="VB" %>

Source File: /Equipment/global.asax    Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

 

I don't know why it is only happening with this one web app.

Very frustrating.

Update: This has been resolved.  The problem is obvious now.  This was a web application that had been converted to a Web Site Project.  When I tried to reimport the files manually into a new Web Application Project there was one minor, yet major, difference that was causing it to fail.  The "CodeBehind" attribute had been changed to "CodeFile".  I didn't think much of it at the time, but of course this indicates that it is going to actually USE the codefile when the page is accessed.  By having a CodeFile attribute AND compiling the code into a DLL, I was ending up with copies of every class.

Categories: Programming | .Net | ASP.Net | VS.Net | Rants
Thursday, April 20, 2006 5:00:08 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Upgrading ASP.NET to 2005? Check your references.#

Some of my web applications that I have recently upgraded to 2005 at some point had their references changed to point to the DLLs that were already in the bin directory.

Of course this was causing all kinds of problems with missing DLLs and compile problems.

Make sure you check your references to see that they are not just pointed back into the bin.

 

Categories: Programming | ASP.Net | VS.Net
Thursday, April 20, 2006 4:32:51 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

App.Config functionality for Class Library Assembiles#

I was just reading this site:

http://www.bearcanyon.com/dotnet/#AssemblySettings

I downloaded the sample code (link below).  It is supposed to allow you to have a config file per assembley e.g. MyAssembly.dll.config. 

I haven't looked at the code, but I guess you would just write something that uses reflection to find the assembly name, and then look for an xml file to read.

AssemblySettings.zip (10.5 KB)

 

Categories: Programming | .Net | .Net Framework | Tools
Thursday, April 20, 2006 2:25:32 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Sending Datasets and Objects Over the Wire: Serialization and XML#

I have tried to councel against sending datasets across web service calls, but we have a lot of instances where this is being done.

One of the problems with this is that datasets get bloated when converted to XML.

So I set out to compare the sizes of:

  1. Serialized List(Of MyType)
  2. Serialized DataTable
  3. Serialized DataSet
  4. XML Serialized Dataset

I wish I had done some research on this, because I would have quickly been reminded that DataSets always serialize as XML, even if you are using the BinaryFormatter. 

There are lots of people out there coming up with their own ideas for how to improve the serialization of datasets:

Anyway, this isn't really THAT big of a deal, because my real goal wasn't to improve the dataset serialization, but to simply see what it would be, and compare it to some other ways to serialize data, like in a list of business objects or a datatable.

The results are interesting:

Given a list of 1013 Business Objects (Records) the serialization results are as follows:

Method Size (bytes)
List(Of MyType) 290,321
DataTable 819,575
DataSet 693,088
XML Serialzied Dataset 851,614

I have read that you can really decrease the size of the dataset by writing your own logic to do the serialization, but as everyone points out that is kind of a pain.


Categories: Interesting | Programming | .Net | ASP.Net | WebServices | XML
Thursday, April 20, 2006 1:44:19 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Byte Array To String#
Here is a very simple code snippet for converting a Byte Array to a String in VB.Net

Encoding.ASCII.GetString(bytes)



And here is a function for that uses it to convert a byte array to a string

    
Private Function streamToString(ByVal stream As System.IO.MemoryStream) As String
Dim o As New IO.StreamWriter(stream, System.Text.Encoding.Default)
Dim bytes(stream.Length - 1) As Byte
stream.Read(bytes, 0, stream.Length - 1)
Return Encoding.ASCII.GetString(bytes)
End Function

Categories: Programming | .Net | VB.Net | References
Thursday, April 20, 2006 9:58:39 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Implementing System.ICloneable and a Snippet#
This will provide the necessary functions to implement ICloneable as well as a type specific Clone method.
        
Public Function Clone() As ClassName
Dim bFormatter As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim stream As New System.IO.MemoryStream()
bFormatter.Serialize(stream, Me)
stream.Seek(0, System.IO.SeekOrigin.Begin)
Dim newClone As ClassName
newClone = CType(bFormatter.Deserialize(stream), ClassName)
Return newClone
End Function
Private Function ICloneableImplementation() As Object Implements System.ICloneable.Clone
Return Me.Clone
End Function


I wrapped this into a snippet that you can import into Visual Studio 2005.

Implement ICloneable.snippet (1.84 KB)


Categories: Programming | .Net | VB.Net | VS.Net | Tools
Thursday, April 20, 2006 9:00:40 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS2005: C# Projects Get Reference Folder VB Doesn't#

In VS.Net 2003 projects had a little sub folder looking icon called References that you could quickly expance to see what assemblies are being referenced. 

In 2005, you have to open a projects page and navigate to the references tab, but only for VB.Net projects.  C# projects still get the nice shortcut.  Weird.

Categories: Programming | .Net | C# | VB.Net | VS.Net
Wednesday, April 19, 2006 3:51:13 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS.Net 2005 Uses Wrong DLL For Reference#

I just came across another bug in VS.Net 2005.

When I went to upgrade some of my projects from 2003 to 2005 I copied them to a new folder.  So for the sake of simplicity lets say that my projects were in C:\Projects\ and the 2005 versions are in C:\Projects2005\.

Some of the projects had a reference to a DLL located in C:\Projects\MyDLL, so when you run the upgrade wizard, it adds C:\Projects\MyDLL as a reference path for your new project located in C:\Projects2005.

Now here is what ticked me off.

I had already taken the code from MyDLL and upgraded it to 2005, built the DLL, and put the DLL in C:\Projects2005\MyDLL.

So if you convert a project, it doesn't know about that new 2005 version of MyDLL, so I was nice enough to go in, remove the 2003 reference, and repoint it to the 2005 version.

However, at this point it says "Oh I see you want me to use this DLL, but it looks like there is one with the same (whatever criteria it uses, maybe just the name?) in my reference path (C:\Projects\MyDLL), so I'll just throw out whatever you were asking me to do and reference that one" which is EXACTLY what I didn't want it to do.

Categories: Programming | .Net | VS.Net
Wednesday, April 19, 2006 3:41:09 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS 2005: Remove Project=Lose Reference #

I had been really bugged by the way VS.Net 2005 seemed to treate project references.

As I mentioned in a previous post, if you remove a project from a solution, all references to that project are also removed from their respective project.

The result is that lots of project suddenly lose reference to a needed dll or project, and you have to go back and manually add the reference back in.  Big pain.

Thankfully, Mikhail Arkhipov from Microsoft has reassured me that 1) I am not going crazy, 2) this is not by design as in fact a bug, and 3) it will be fixed in a (hopefully soon to be released) service pack. 

Strike 1 issue with VS.Net 2005.  Only like 10 more to go.

Categories: Programming | .Net | VS.Net
Wednesday, April 19, 2006 3:16:03 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

SEO#

Search engine optmization is the efforts to increase a website's ranking in the various search engines.

One site that I have been using, mostly for fun, is http://www.googlerankings.com which, unlike other sites that just tell you the page rank of your site, will allow you to provide a search term, and it will try to find your site on the google, msn, and yahoo. 

You just need to provide your Google API key:

Of course, finding that your site is number 836 for some search doesn't really help you in any meaningful way, other than to know that no one is ever going to find your site through that search engine.

I was trying to see who my site is listed number 2 at MSN for "Chris May" but not even in the top 1000 at google or yahoo.  

Categories: Networking | SEO
Wednesday, April 19, 2006 8:24:15 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Which Is Worse#

Which is worse?

The fact that I spend so much time working at Borders, that when they hire a new barista I notice, or the fact that I spend so much time working at Borders that the new barista notices that I used to have a beard.

Categories: Thoughts
Wednesday, April 19, 2006 7:44:31 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Ticketmaster Sucks!!!#

OMG TicketMaster Sucks!!!

I just went to buy some tickets for The Secret Machines, and the tickets were 15 bucks each. 

I picked the FREE delivery option, and my order came to $72.30.  WHAT???  3 tickts @ $15 << $72.30.

So for a 15 dollar ticket, they add on a "facility charge" of another buck, then there is the "Convenience Charge" WTF is that BS?  Tax is only 1.50 but then they throw on a "Order Processing Fee" charge of 4.80?? What the hell is the difference between their Order processing fee, and their Convenience charge?  This is totally gay.

In the end my "tickets" cost 60% more than the cost of the "tickets"!!

Ticketmaster really sucks ass.  I hate them with a passion.

And how come I keep signing up to be notified when some bands go on tour and they never email me, those ass hats.

Item Charge
 
Full Price Tickets US $15.00 x 3
Facility Charge US $1.00 x 3
Convenience Charge US $6.25 x 3

Additional Taxes US $0.75
   
Delivery (Standard Mail) No Charge
Order Processing Fee US $4.80
Additional Taxes US $0.75
   
Total Charges US $72.30

Categories: Rants
Tuesday, April 18, 2006 2:59:14 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Upgrading to 2005 Continuing To Be A Pain#

I decided to go with Scott Gu's suggestion to use Web Application Projects to help ease the conversion for 2003.

I will agree that this is a much better way to convert your project than to turn it into a Web Site Project, but there are still lingering problems.

In one of my projects the web page and code behind have somehow become lost.  The code behind pages can't see their controls, which are placed in some mystery file thanks to the new Partial Class feature.

I tried ranaming the files, I tried cutting and then replacing the HTML that defines the controls, the only thing I found that works is to totally delete the file and recreate it exactly the same way.  What a pain.

The "What a pain" concept is the only constant in this process.

I am still not sure what is going on with project references. 

As far as I see, if there is a DLL in the bin directory, you don't need a reference to that DLL.  But as soon as you clean out your bin, your project will break with error messages that are nothing like "Are you missing a reference?" because, of course you are, VS.Net just removes them all the time w/o asking you! 

There must be some new paradigm with how you are supposed to work with references, projects, and solutions, because trying to do it like you would in vs.net 2003 is causing a ton of problems.

Update: Almost as if VS was getting back at me, as soon as I posted this it took a crap and crashed.  :-)

Categories: Programming | .Net | ASP.Net | Rants
Monday, April 17, 2006 6:16:34 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

University of Chicago First Grades#

I just got my first set of grades from University of Chicago.  I got an A in OO Architecture and Design Patterns, and a B in Software Construction.

I think I couldn't have done any better than a B in Software Construction.  The work was very challenging, in a good way, but the time requirement was so great that week after week I wasn't able to complete the weeks assignment, or if I was able to complete it, my code wasn't as strong as it could have been.

I am taking this quater off to focus on work, and I am not sure if I will be taking anything in the summer as they usually do the really basic classes then.  We will see. 

I probably still need to take some kind of discrete math class, but I don't want to pay the $3600 bucks to take it at UofC if I can take it elsewhere for less.

Categories: University of Chicago
Sunday, April 16, 2006 10:25:35 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Bret Martin and Katie Kniss Are Getting Married#

Bret Martin and Katie Kniss

Bret Martin and Katie Kniss are getting married

I am going to see if I can get a googlewhack on Bret Martin and Katie Kniss, linking to this page.  Technically a googlewhack is 2 words that are in the dictionary, but I am expanding on this to include names.

Putting their names in some H1 and H2 tags at the top here should help with the Googlebot.

Bret Martin and Katie Kniss are getting married.


Actually, Katie is probably getting the raw end of this deal, she is going to have to put up with Bret for years to come. 

Same goes for Kathleen.  Sometimes I wonder if knew what she was getting herself into.  :-)

The wedding is this summer in St. Louis, and I hear they are spending their honeymoon in Peoria.  Well not just Peoria... East Peoria. 


Update: Well I got my home page number 1 on the major 3 search engines:
Google
Yahoo
MSN

But they are only indexing my homepage right now, not the actual article link (Bret Martin and Katie Kniss).

Categories: Funny Stuff | Misc | Thoughts
Sunday, April 16, 2006 12:54:14 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Citrix Alternatives?#

Slashdot is running an Ask /. article on alternatives to Citrix.

At Walsh, we run a lot of applications over Citrix, mostly apps that really aren't meant to be run remotely, to allow remote users to run them against databases that are stored in our main offices.

MSi is interested in a solution such as this as well but for more daily operations than specific application access.

Categories: Servers | Networking | Software | Windows
Saturday, April 15, 2006 11:20:02 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VB.Net: Passing Reference and Value Objects ByRef and ByVal#

Here is a little example of how vb.net deals with passing of objects ByRef and ByVal.  The short answer is that when you pass a reference type object (not a value type) byval, the object is copied back when the method if finished.  You never really have handle on the original object, which is evident by the fact that you can't set it = nothing.  However, if you pass ByRef then you can indeed set the object = nothing and it will remain null when you return to the calling function.

If you try the same thing, except using a value type structure, you will see almost the same behavior, except for the major differenct that if you pass a structure byval and then make a change to it, those changes will not be copied back to the calling function.

To see an example of this check out the code by clicking on the "More" button to read the full article. 
Categories: Programming | .Net | .Net Framework | VB.Net
Saturday, April 15, 2006 1:04:46 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

dasBlog Category Rename#

Here is a link to a tool that will go through a collection of blog entries and rename them.  Just what I was looking for.

http://www.vasanth.in/Software.aspx?=renamer

 

Categories: Blogging
Saturday, April 15, 2006 12:13:13 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

QofSA - Over the Years and Through The Woods#

I just finished watching Over the Years and Through The Woods which I first blogged about here.

It was pretty cool!  If you like Queens of the Stone Age, then you should really get it.

The performances reminded me of the one thing that they do live that I don't like, and that is take an adlib section too far.  It's like, oh cool, normally this part only goes on 4 times but they are doing it more, ok, thats 12, 16, ...  ok 24 times ... ok... this is getting stupid, I lost track of the count, are they ever going to jump back into the song?

But the DVD is pretty cool.  There are some cool bonus footage of a bunch of the songs I really like with their old bass player that they don't play live anymore, which sucks.  I think they were a lot better w/ him in 2003 than w/o.  But whatever.

I found this other CD by them that I might end up getting called The Desert Sessions

Cool stuff.

Categories: Cool | Movies | Music
Friday, April 14, 2006 5:34:23 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

From Asp.net 1.1 to 2.0: Parser Error - Could not load type 'xyz.Global'#

As we were upgrading to run ASP.Net 2.0, we ran into this wonderful problem.  Your code seems to run fine until you push it to a server and you get this error:

 Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'xyz.Global'.
Source Error:

Line 1:  <%@ Application Inherits="xyz.Global" Language="VB" %>
Source File: /global.asax    Line: 1

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

 

There are 2 things I had to remember to do to get this to work.

1) We use a domain user for the aps.net worker process, so our site can access UNC files across the network.  In order for this user to have the ability to compile the app, you have to give them full rights to: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 and if you start running your apps in .net 2.0, you need to do the same for c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

2) If you have any web apps running in 1.1, there is a good chance that even thought you changed the iis setting to asp.net 2.X, you are still running against an app pool that is shared with another site using asp.net 1.1.  So, just create a new app pool, and have your newly 2.0 site setup to use that app pool.

Problem solved!

Categories: Programming | .Net | ASP.Net
Thursday, April 13, 2006 6:05:37 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

VS.Net 2005, Projects, Solutions, and References: What was MS thinking??? This SUCKS!!!!#

This is really shocking (and very disappointing) to me.

I had the task of upgrading the code base at Walsh Construction from .net 1.1 to 2.0 and putting it all in a source control database.

I had been getting a lot of totally random build problems, and I started wondering: Where does it store my references?

ASP.Net Web Sites projects don't have a vbproj or csproj file anymore, so where is it storing the fact that I want this website to have a references to a given DLL or a given project in my solution?

I found that the answer is that the project references are stored in the solution file! 

If you open up the solution file you will find lots of stuff like this:

ProjectSection(WebsiteProperties) = preProject
ProjectReferences = "{E050AEA3-6DCA-4DE8-936F-5A8B14A912B9}|MyReferencedAssembly.dll;

This is kinda stupid.

Non-website projects keep a list of their references in their project file.

Websites keep SOME reference info in their web.config, although I think that is only for DLLs that are in the GAC.

Anyway on to the list of things that truly suck about how this works:

1)  When you add a reference from a web project to a DLL, the DLL is copied to the Bin directory right then, as opposed to when you do the build.  I bet it does it at build-time as well, but what really sucks is that you can have a situation where WebSiteA references ComponentA which references DataAccessLayerA.  WebSiteA will have DataAccessLayerA.dll in it's bin directory, then if you go to add a references from WebSiteA to DataAccessLayerA, it will say "Oh you already have a reference" when you really don't, and if you try to build it won't work until you go delete that dll from your bin and add the reference.

2)  I have been unable to open some projects without opening the entire solution that I joined them too at one point.  Basically as I was converting all our projects over to 2003 I wanted to also change them from DLL references to project references.  So I created a solution with ever project and website we have in .net.  To illustrate my problem, I added a project to the solution called IAmABogusProject with 1 class and 1 static method.  No one uses this class, no projects have a reference to this project, and this project has no references to any other projects.  Yet, if I go click on the vbproj file for this project, it loads up my solution file with every single project.  I tried creating another solution and adding it to that one to see if it would open the new solution when I tried to reopen the project but no luck, it opened original solution with every application again!! WTF!!

3) This is the worst of the list.  If you have a project in a solution that is referenced by some other projects and you remove that project from the solution, guess what happens?  In 2003 it would remove the project and all the referencing projects would show a missing reference icon.  In 2005 it checks out all the referencing projects and removes the reference!!!  Are you kidding me???  For the cherry on top, you have to then manually add all the references back after you add the project back into the solution, and of course you get all kinds of weird bugs, none telling you that you are missing an assembly reference.  Totally stupid.   This is a bug, see Update3 at the bottom.

I am really pissed about this.  Why do MS product upgrades frequently come with a "What were they thinking?" tag? 

Maybe the roll of the solution has changed or something, but this is going to really piss me off working like this day to day.

I have already had something happen where all my website projects that I had already added to source control lost their binding.  Great....

Update1:  I am continuing to have problems with my web project "losing" references that I have to keep setting.  What a pain this is becoming!

Update2: Scott Gu from Microsoft (http://weblogs.asp.net/scottgu) suggested that I give the Web Application projects a try.  I had tried them once before when in beta and remembered there was something that was a show stopper at the time.  I don't remember exactly what, maybe the designer didn't work?  Anyway, that could solve a few of my issues, but this whole thing of not being able to open a project without a solution getting opened, and the thing where VS removes references from projects (even if they are under source control) if you remove the project from a solution is crazy.

Update3: Well thank God, someone from Microsoft let me know that this thing with removing a project causing references to disappear is actually a bug: http://www.chrismay.org/2006/04/19/VS2005RemoveProjectLoseReference.aspx 

Categories: Programming | .Net | VS.Net | Projects | Rants
Thursday, April 13, 2006 4:44:19 PM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

Quickbooks Integration#
AcctSync is a .NET SDK for integrating stuff into quickbooks.

Update: I first made this post in 2003, but I have another client that is going to be looking to do something with Quickbooks.  Might want to revisit this component in the near future.
Categories: Programming | Tools
Thursday, April 13, 2006 3:40:26 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Running ASP.NET Development Server Without Virtual Path, From Root#

I had been looking for a way to get the asp.net development server to run w/o a virtual directory settings.  It's really very stupid and short sighted to not enable this.  Just about every project I have ever worked on has some paths coded into the HTML that are based on / being the root, not the application root.  Stupid.

 

Anyway, ScottGu posted these steps on his site, and it works.  Not bad!

Step 1: Select the “Tools->External Tools” menu option in VS or Visual Web Developer.  This will allow you to configure and add new menu items to your Tools menu.

 

Step 2: Click the “Add” button to add a new external tool menu item.  Name it “WebServer on Port 8080” (or anything else you want).

 

Step 3: For the “Command” textbox setting enter this value: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.EXE (note: this points to the web-server that VS usually automatically runs).

 

Step 4: For the “Arguments” textbox setting enter this value: /port:8080 /path:$(ProjectDir)

 

Step 5: Select the “Use Output Window” checkbox (this will prevent the command-shell window from popping up.

 

 Once you hit apply and ok you will now have a new menu item in your “Tools” menu called “WebServer on Port 8080”.  You can now select any web project in your solution and then choose this menu option to launch a web-server that has a root site on port 8080 (or whatever other port you want) for the project.

 

You can then connect to this site in a browser by simply saying http://localhost:8080/.  All root based references will work fine.

 

Step 6: The last step is to configure your web project to automatically reference this web-server when you run or debug a site instead of launching the built-in web-server itself.  To-do this, select your web-project in the solution explorer, right click and select “property pages”.  Select the “start options” setting on the left, and under server change the radio button value from the default (which is use built-in webserver) to instead be “Use custom server”.  Then set the Base URL value to be: http://localhost:8080/

Categories: Code Links | ASP.Net | VS.Net
Wednesday, April 12, 2006 1:42:57 PM (Central Daylight Time, UTC-05:00) #    Comments [3]  | 

 

Essence Theme#

The current theme on this site was created by Jelle Druyts.  I just emailed him looking for an idea to solve the problem of the left column dropping to the bottom of the page if you narrow the window.

I was kinda suprised to see his site when I clicked on the link for the theme creator because I have been to his blog a few times before, obviously for some .net programming stuff.

I am going to take a look at his categories b/c I long ago gave up on using categories in BlogX b/c you could only search in 1 category.  So if I knew I had saved some URL in my blog I would have to search in every category in order to find it.

Now that I am using dasBlog, I should be reorganizing my categories.

Categories: Blogging
Wednesday, April 12, 2006 9:44:59 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Morning Commute#

I tried wearing a new pair of shoes yesterday (big mistake) and on my walk to the train I got a giant blister on my left foot.

Damn it hurts!

So today I decided to drive to avoid the walk to/from the train station, and something terrible happened.  I actually ended up looking for "the mix" on my car radio.  I am ashamed.

Kathleen has been putting it on every morning, and my usual stations were not doing anything intersting.  The Score had Mike North saying something racist, 720 and 780 were on commerical, 850 was some terrible show I have never heard before, and ESPN was talking about golf.

Lucky for me the mix quickly went to commerical, so I was able to come to my senses.

Categories: Thoughts
Wednesday, April 12, 2006 9:27:33 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Databinding in .Net 2.0 (DNR TV)#

Brian Noyes is the guest on DNR TV to cover databinding in .Net 2.0.

The video can bee seen here.

Categories: Code Links | .Net Framework | Web Site Links
Monday, April 10, 2006 6:26:51 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Expert VB 2005 Business Objects eBook#

Here is the link to get the book in beta:
http://www.apress.com/book/bookDisplay.html?bID=10090

Expert VB 2005 Business Objects takes you from an opening discussion of logical architectures to detailed n-tier deployment options using the CSLA .NET Framework. Rockford provides enough understanding and detail for you to take this approach to your own projects, as many developers have already done.

Categories: Web Site Links | VB.Net
Monday, April 10, 2006 6:23:05 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Implementing ICloneable While Staying Type Safe#

I had always had issue with implementing ICloneable in the .Net Framework on my classes.  Implementing ICloneable requires that you return an Object, but a lot of time you don't want to return an Object type, you want to return a strongly typed object of type whatever.

Well, thanks to a tip I heard on .NetRocks from Rocky Lhotka, I have coded up an example of how you can a) Implement ICloneable, and b) return a strongly typed object from your Clone method.

Imports System

Public Class BusinessObject
Implements ICloneable
Private Function privateClone() As Object Implements ICloneable.Clone
Dim MyClone As Object = makeClone()
Return MyClone
End Function
Public Function Clone() As BusinessObject
Dim MyClone As BusinessObject = makeClone()
Return MyClone
End Function
Private Function makeClone() As BusinessObject
'*** do the clone here
End Function End Class

The trick is to implement ICloneable as a private function.  To be honest I have no idea why this works.  You would think that implementing the Clone method as a private function would mean that you couldn't access it, but as the code I wrote below shows, it does work.

imports Microsoft.VisualBasic
imports System
imports System.Collections

public module MyModule
    sub Main
RL()
        dim o as new BusinessObject
        WL("IClone " & o.Clone.IClone)
        WL("StandardClone " & o.Clone.StandardClone)
        dim i as System.ICloneable
        i = ctype(o, System.ICloneable)
        WL("IClone " & ctype(i.Clone,BusinessObject).IClone)
        WL("StandardClone " & ctype(i.Clone,BusinessObject).StandardClone)
        RL()
    end sub

    #region "Helper methods"

    sub WL(text as object)
        Console.WriteLine(text)
    end sub

    sub WL(text as object, paramarray args as object())
        Console.WriteLine(text.ToString(), args)
    end sub
        
    sub RL()
        Console.ReadLine()
    end sub
    
    sub Break()
        System.Diagnostics.Debugger.Break()
    end sub

#end region

end module


public Class BusinessObject
Implements System.ICloneable
    public IClone as string = ""
    public StandardClone as string = ""

Private Function privateClone() As Object Implements ICloneable.Clone
Dim MyClone As Object = makeClone()
        ctype(MyClone,BusinessObject).IClone = "true"
Return MyClone
End Function

Public Function Clone() As BusinessObject
Dim MyClone As BusinessObject = makeClone()
        MyClone.StandardClone = "true"
Return MyClone
End Function

Private Function makeClone() As BusinessObject
'*** do the clone here
        return new BusinessObject
End Function

End Class

I will have to get to the bottom of this private thing.  But at least this will work and do you want expect it to.

Update: I got some answers from a couple people online.
Alvin Bruney (
http://msmvps.com/blogs/Alvin/ ) suggested:

The modify tag, private, does not apply to the compiler. It is capable of
calling the method. The tag is applicable only to calling code.

This I knew, but I guess I was wondering why the compiler allows you to do this.  I guess it makes sense that the interface makes that method public, so public it is!   Case closed

Categories: .Net Framework | VB.Net | C#
Monday, April 10, 2006 9:10:44 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

CLSA on .NetRocks 2#

This is the original blog post from Rocky Lhotka about doing the .NetRocks show:
http://www.lhotka.net/WeBlog/dotnetrocksInterviewOnCSLANET20.aspx

Categories: Web Site Links
Sunday, April 09, 2006 7:57:59 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

CLSA.Net on DotNetRocks#

I am going to be getting Rocky Lhotka's new book, which is available in ebook form before he comes to speak at the CNUG group in DG.

In addition, he has taped 2 sessions with DotNetRocks available here and here.

I'm watching one of them now.

Categories: Web Site Links
Sunday, April 09, 2006 5:29:56 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Testing Trackback / Image / File / Google filters.#

With this post I am testing out some features of dasBlog.

I am linking to a Trackback faq page by Shai Coggins seen below thanks to the upload image feature (not bad eh?).



It looks like dasBlog just throws these uploaded images into a single folder, which I guess means I could overwrite a file if 2 were uploaded with the same name.  Lemme try...

Yep, it overwrote it.  I guess I will have to be careful about that possible occurance.

On to the file upload option:

Sequencediagram_1.png (1.84 KB)

Interesting, thats pretty cool.

The last thing to test is the content filter ability.

This seems a bit much, you type in a bunch of code and it will output some standard string.  For example, this should produce a google search: chrismay and this should produce an IMDB search: $imdb(The Matrix).

Here goes...

Update
Well it seems that everything worked pretty well except maybe the trackback isn't working.  The URL for the trackback appears to not be saved when I save this article, but maybe that is by design.  I will have to look into it.  I posted a comment on the article I was trying to trackback... maybe that output is cached and it will show up later (?), doupt it.  Here is the article I am dealing with.

Categories: Blogging
Sunday, April 09, 2006 4:23:54 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Indents Fixed! #

Well a little tweaking of the code that does the generation of the formatted code, and it now produces what I want:

        Public Shared Function AddTOQueryString(ByVal URL As String, ByVal Key As String, ByVal Value As String) As String
Dim RegExp As New System.Text.RegularExpressions.Regex(Key & "=.*?(&|$)")
Dim Match As System.Text.RegularExpressions.Match = RegExp.Match(URL)
If Match.Success Then
Return RegExp.Replace(URL, Key & "=" & Value & Match.Groups(1).ToString)
ElseIf URL.IndexOf("?") > 0 Then
Return URL & "&" & Key & "=" & Value
Else
Return URL & "?" & Key & "=" & Value
End If
End Function
        /// <summary>Gets or sets the RSS version to write.</summary>
        /// <exception cref="InvalidOperationException">Can't change version number after data has been written.</exception>
        public RssVersion Version
        {
            get { return rssVersion; }
            set
            {
                if(wroteStartDocument)
                    throw new InvalidOperationException("Can't change version number after data has been written.");
                else
                    rssVersion = value;
            }
        }

I am not sure that I like what it does with literal strings.  I will probably want to change that.

I am also now convinced that it will not due for formatting Javascript.  J# just doesn't share enough similar attributes.  This tool also doesn't support XML (or HTML), which would be a nice thing too.

This converter looks pretty sweet.  You can include your regions and it will let you keep them collapsed and then expand via javascript, excellent.

I could also just wire up the implementation I already have to deal with HTML and Javascript.

We will see... for now this will do.

Categories: Blogging | VB.Net
Sunday, April 09, 2006 12:51:00 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

HttpFilters, HttpModules, and HttpWastedABunchOfTime#

I was just about to make a post talking about the switch over to dasBlog.  I was going to talk about what I liked and didn't like and whatever, but mostly I was going to talk about the work I have been putting in on writing code that will filter out code and format it nicely.

I wrote and tested an HttpModule which loads a Reponse Filter that parses the Html looking for <code> tags and formats the code inside those nicely.

So I go to write my first post, and I am looking for a hyperlink button in the texteditor, but instead I see this icon that look like a C# file.  "No, I did not just waste all that time" I thought. 

public bool IsTimeWasted(String name){
    return true;
}

Public Function IsWasted(ByVal time As TimeSpent) As Boolean
  If time IsNot Nothing Then
    Return True
  Else
    Return False
  End If
End Function

var s;
s = 'asdf';
document.getElementById("asdf"); /* comment */

SELECT * FROM
ThingsToDo
WHERE
WastedTime <> 1
AND
Task = 'Writing HttpFilter'


0 rows returned

So you can see I basically wasted my time doing all that.

This tool doesn't provide an HTML code type, and I used J# in place of Javascript, but it works ok I guess.

The on thing it is really lacking is that it doesn't maintain indents!?!?  I manually restored the indents above, otherwise my vb code would look like this:

Public Function IsWasted(ByVal time As TimeSpent) As Boolean
If time IsNot Nothing Then
Return True
Else
Return False
End If
End Function

Which is weird, b/c it looks fine in the preview window... I will have to look into that.

 

 

Categories: Blogging | Code Link | VB.Net
Saturday, April 08, 2006 7:54:09 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

dasBlog conversion complete#

Well I have switched over to dasBlog.

Awww crap.  I need to start a new post...

Categories: Blogging
Saturday, April 08, 2006 6:15:43 PM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

HttpFilter and HttpModules#
Here is another article on the topic, but they cover the use of an HttpModule instead, which is supposed to make it so you don't have to manually install the HttpFilter in your code.
Categories: ASP.Net
Thursday, April 06, 2006 8:50:10 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

dasBlog and httpfilters#
Apparently there is a cool blogging app called dasBlog, which means "That Blog" in German :), that provides a lot of better features when compared with my old blogX, and even better it provides a direct upgrade from blogX, so I don't have to write my own scripts to do the conversion to what I was going to use (newblog on DNN).

The downside is that I had already written the necessary code to parse and replace ... well... "code"... in my blog posts into pretty formatted HTML.

It worked like this... I would type something like [code type=vb]Dim s as New System.Text.StringBuilder [/code] and it comes out looking like:
Dim s as New System.Text.StringBuilder 

So that is pretty cool... but I think I can get the same result, and maybe make it even cleaner, by using an httpfilter.

HttpFilters are registered at application startup and are sent the html just before it gets passed to the browser, so you can use the filters as like a last change modification mechanism. Hopefully I can write some regexps to parse out what I want and replace it with the new stuff.
Categories: Blogging
Thursday, April 06, 2006 8:41:25 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Format String#
The following content has been cut and pasted from Kathy Kam's Blog. The article was Format String 101.


 

I see stuff like {0,-8:G2} passed in as a format string. What exactly does that do?" -- Very Confused String Formatter

The above format can be translated into this:

"{<argument index>[,<alignment>][:<formatString><zeros>]}"

argument index: This represent which argument goes into the string.

String.Format("first = {0};second = {1}", "apple", "orange");

String.Format("first = {1};second = {0}", "apple", "orange");

 

gives the following strings:

 

"first = apple;second = orange"

"first = orange;second = apple"

 

alignment (optional): This represent the minimal length of the string.

Postive values, the string argument will be right justified and if the string is not long enough, the string will be padded with spaces on the left.

Negative values, the string argument will be left justied and if the string is not long enough, the string will be padded with spaces on the right.

If this value was not specified, we will default to the length of the string argument.

 

String.Format("{0,-10}", "apple");      //"apple     "

String.Format("{0,10}", "apple");       //"     apple"

format string (optional): This represent the format code.

Numeric format specifier is available here. (e.g. C, G...etc.)
Datetime format specifier is available here.

Enumeration format specifier is available here.

Custom Numeric format specifier is available here. (e.g. 0. #...etc.)

 

Custom formatting is kinda hard to understand. The best way I know how to explain something is via code:

 

int pos = 10;

int neg = -10;

int bigpos = 123456;

int bigneg = -123456;

int zero = 0;

string strInt = "120ab";

 

String.Format("{0:00000}", pos);      //"00010"

String.Format("{0:00000}", neg);      //"-00010"

String.Format("{0:00000}", bigpos);   //"123456"

String.Format("{0:00000}", bigneg);   //"-123456"

String.Format("{0:00000}", zero);     //"00000"

String.Format("{0:00000}", strInt);   //"120ab"

String.Format("{0:#####}", pos);      //"10"

String.Format("{0:#####}", neg);      //"-10"

String.Format("{0:#####}", bigpos);   //"123456"

String.Format("{0:#####}", bigneg);   //"-123456"

String.Format("{0:#####}", zero);     //""

String.Format("{0:#####}", strInt);   //"120ab"

 

While playing around with this, I made an interesting observation:

 

String.Format("{0:X00000}", pos);      //"A"

String.Format("{0:X00000}", neg);      //"FFFFFFF6"

String.Format("{0:X#####}", pos);      //"X10"

String.Format("{0:X#####}", neg);      //"-X10"

 

The "0" specifier works well with other numeric specifier, but the "#" doesn't. Umm... I think the "Custom Numeric Format String" probably deserve a whole post of it's own. Since this is only the "101" post, I'll move on to the next argument in the format string.

 

 

zeros (optional): It actually has a different meaning depending on which numeric specifier you use.

 

int neg = -10;

int pos = 10;

 

// C or c (Currency): It represent how many decimal place of zeros to show.

String.Format("{0:C4}", pos);      //"$10.0000"

String.Format("{0:C4}", neg);      //"($10.0000)"

 

// D or d (Decimal): It represent leading zeros

String.Format("{0:D4}", pos);      //"0010"

String.Format("{0:D4}", neg);      //"-0010"

 

// E or e (Exponential): It represent how many decimal places of zeros to show.

String.Format("{0:E4}", pos);      //"1.0000E+001"

String.Format("{0:E4}", neg);      //"-1.0000E+001"

 

// F or f (Fixed-point): It represent how many decimal places of zeros to show.

String.Format("{0:F4}", pos);      //"10.0000"

String.Format("{0:F4}", neg);      //"-10.0000"

 

// G or g (General): This does nothing

String.Format("{0:G4}", pos);      //"10"

String.Format("{0:G4}", neg);      //"-10"

 

// N or n (Number): It represent how many decimal places of zeros to show.

String.Format("{0:N4}", pos);      //"10"

String.Format("{0:N4}", neg);      //"-10"

 

// P or p (Percent): It represent how many decimal places of zeros to show.

String.Format("{0:P4}", pos);      //"1,000.0000%"

String.Format("{0:P4}", neg);      //"-1,000.0000%"

 

// R or r (Round-Trip): This is invalid, FormatException is thrown.

String.Format("{0:R4}", pos);      //FormatException thrown

String.Format("{0:R4}", neg);      //FormatException thrown

 

// X or x (Hex): It represent leading zeros

String.Format("{0:X4}", pos);      //"000A"

String.Format("{0:X4}", neg);      //"FFFFFFF6"

 

// nothing: This is invalid, no exception is thrown.

String.Format("{0:4}", pos));      //"4"

String.Format("{0:4}", neg));      //"-4"

 

In summary, there are four types of behaviour when using this <zeros> specifier:

Leading Zeros: D, X

Trailing Zeros: C, E, F, N, P

Nothing: G

Invalid: R, <empty>

 

Now, that we've gone through the valid specifiers, you can actually use this in more than just String.Format(). For example, when using this with Byte.ToString():

 

Byte b = 10;

b.ToString("D4");      //"0010"

b.ToString("X4");      //"000A"

 

Wow... this was way longer than I expected. The BCL team is having blog day today, I need to get back to posting something for the BCLWeblog.

<Editorial Comment>

One of the lesson I learnt from an earlier post is that, readers are not interested in a post that doesn't give you more information than what MSDN provides. Instead, readers are more interested in seeing stuff that are not available on MSDN. So when I was doing research to post about this topic, I found that MSDN actually talks about exactly what the {0,-8:G2} format does. It is just not easy to find nor centrally located.

For example, in the ToString MSDN Doc, the "Remarks" section covered some basic rules on what a "format string" is. In the String.Format MSDN Doc, the "Remarks" section actually have a pretty detail explaination of what the above format does. Furthermore, MSDN provides a format string overview as well as a the table that specifies all the values that are allowed.

This puts me in an interesting position when writing about this topic. MSDN actually have lots of info that cover it. But since I have also heard more than one person being confused about this topic, I decided to post a summary of the documents and more examples. Do you think this is useful? Should I just stick to posting exclusively on non-MSDN topics?

</Editorial Comment>

Categories: T-Sql
Wednesday, April 05, 2006 11:50:22 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Death of Dime (and WS-Attachments)#
DIME and WS-Attachments are basically dead.

MTOM (SOAP Message Transmission Optimization Mechanism) has shown up on MSDN (xml messaging page), and DIME, SwA, and PASwA are marked as superseded.

I have seen some places describing MTOM as basically the same thing as XOP (XML-binary Optimized Packaging), not sure if that is true or whatever, but it seems the message is clear: DIME is yesterdays news.
Categories: WebServices
Wednesday, April 05, 2006 11:08:14 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

Some options for converting DATETIME in SQL to different formats using CONVERT()#
To see the effects, just run this script against your database:

PRINT '1) HERE IS MON DD YYYY HH:MIAM (OR PM) FORMAT ==>' +
CONVERT(CHAR(19),GETDATE()) 
PRINT '2) HERE IS MM-DD-YY FORMAT ==>' +
CONVERT(CHAR(8),GETDATE(),10) 
PRINT '3) HERE IS MM-DD-YYYY FORMAT ==>' +
CONVERT(CHAR(10),GETDATE(),110)
PRINT '4) HERE IS DD MON YYYY FORMAT ==>' +
CONVERT(CHAR(11),GETDATE(),106)
PRINT '5) HERE IS DD MON YY FORMAT ==>' +
CONVERT(CHAR(9),GETDATE(),6)
PRINT '6) HERE IS DD MON YYYY HH:MM:SS:MMM(24H) FORMAT ==>' +
CONVERT(CHAR(24),GETDATE(),113)

Categories: T-Sql
Tuesday, April 04, 2006 9:10:48 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
ASP.NET 2.0 Page Life-cycle
Grant Execute Rights To All SPs
SQL Server Query Results To Excel
Secret Message
VS2005 VB.Net Create Properties From Private Fields
450 Freeware Utilities
applicationSettings, appSettings. app.config, web.config and userSettings
Virtual Server Networking With External Access
Composed vs Comprised
Serialization / Deserialization of Objects With Version Changes
Rocky Lhota at CNUG
Cool Icons
Moving a Network
Fixing Left Column Problem With dasBlog Essence Theme
Delete the Web Apps DLLs and Everything Works
Upgrading ASP.NET to 2005? Check your references.
App.Config functionality for Class Library Assembiles
Sending Datasets and Objects Over the Wire: Serialization and XML
Byte Array To String
Implementing System.ICloneable and a Snippet
VS2005: C# Projects Get Reference Folder VB Doesn't
VS.Net 2005 Uses Wrong DLL For Reference
VS 2005: Remove Project=Lose Reference
SEO
Which Is Worse
Ticketmaster Sucks!!!
Upgrading to 2005 Continuing To Be A Pain
University of Chicago First Grades
Bret Martin and Katie Kniss Are Getting Married
Citrix Alternatives?
VB.Net: Passing Reference and Value Objects ByRef and ByVal
dasBlog Category Rename
QofSA - Over the Years and Through The Woods
From Asp.net 1.1 to 2.0: Parser Error - Could not load type 'xyz.Global'
VS.Net 2005, Projects, Solutions, and References: What was MS thinking??? This SUCKS!!!!
Quickbooks Integration
Running ASP.NET Development Server Without Virtual Path, From Root
Essence Theme
Morning Commute
Databinding in .Net 2.0 (DNR TV)
Expert VB 2005 Business Objects eBook
Implementing ICloneable While Staying Type Safe
CLSA on .NetRocks 2
CLSA.Net on DotNetRocks
Testing Trackback / Image / File / Google filters.
Indents Fixed!
HttpFilters, HttpModules, and HttpWastedABunchOfTime
dasBlog conversion complete
HttpFilter and HttpModules
dasBlog and httpfilters
Format String
Death of Dime (and WS-Attachments)
Some options for converting DATETIME in SQL to different formats using CONVERT()
Google Ads
This site
Calendar
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 2.3.9074.18820

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: