Beware of the Invisible Shield by ZAGG for Iphone

I just coughed up a rediculous amount of money for one of these screen protectors as I know the iphone 4 tends to scratch easily.

I’ve owned iphones going all the way back to the original 2G version and I’ve always used a screen protector on all of them.

I have never been so disappointed as with this piece of crap ZAGG product.

It looks terrible, it doesn’t go one smooth or easy AT ALL, and it’s texture is like rubbery so your finger doesn’t slide on it.

I’ve never had issues with screen protectors on any of my other phones (or my wife’s iphone as well) but this one is the absolute worst.  Garbage!

I hope you can avoid wasting your money like I just did.  Orders something online, there is no way there could be a worse product b/c I’ve used half a dozen others and none come close to being as crappy as this one.

UPDATE: I just tried installing the back protector and it was even worse than the front.

The way they have you apply the the cover is to lay it out using a larger area applicant strip.  You then peel away the large area thing and you are left with the protector in the right place.  Only problem is, the adhesive between the 2 is 100x stronger than the adhesive between the protector and your iphone.  In order to seperate the 2 you have to stretch out the protector and then you are left trying to apply it by hand.  What a total joke. 

Stay clear of this waste.

How to setup port forwarding on the CISCO ASDM 5.2

Go to configuration – > security policy

Add Access Rule

Interface: outside

Action: permit

Source: any

Destination: type in the public IP address, aka the outside interface IP address

Service: “tcp/PORT_NUMBER_HERE”

Click OK (maybe 2 times)

 

Click Apply

 

 

Then click on NAT on the left

Click on Add Static Nat rule

Under “Original”

Interface: Inside

Source: Internal ip address that you want traffic routed to

Under Translated

Interface: outside

Click the radio button that says “Use Interface IP Address”

Check the “Enable PAT” check box

TCP and set both ports to be what you want (i.e. 3389 for RDP)

This NAT part always seems backwards to me, but it works.

Telerik Radgrid Filtering Error

When trying to filter my RadGrid using the built in filtering options, I kept getting an exception on the server:

  Stack: System.ArgumentOutOfRangeException:
  Specified argument was out of the range of valid values.
  Parameter name: index
  at System.Web.UI.ControlCollection.get_Item(Int32 index)
  at Telerik.Web.UI.GridTemplateColumn.GetCurrentFilterValueFromControl(TableCell cell)
  at Telerik.Web.UI.GridColumn.RefreshCurrentFilterValue(GridFilteringItem filteringItem)
  at Telerik.Web.UI.GridFilterCommandEventArgs.ExecuteCommand(Object source)
  at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
  at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
  at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
  at Telerik.Web.UI.GridItem.FireCommandEvent(String commandName, Object commandArgument)
  at Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
  at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
  at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Doing some research I found one guy who solved this problem by removing a duplicate UniqueName on his columns, but unfortunately I didn’t have any duplicates :(.

Turned out that the problem was I, in an effort to disable filtering for some columns that should have a filter option, had stumbled upon a quick solution, which was to use the following markup in my template column:

<FilterTemplate />

Instead of:

AllowFiltering="False"

Having the empty filter template seemed to do the trick visually, but it was causing the errors under the covers.

So if you are getting the error above make sure you are dealing with filters in your template columns correctly.

 

 

Rhino Mocks VB.NET Extension Methods and Expect compiler problems

So today I updated my Rhino Mocks library to the newest version and bam, all my tests broke.

The errors were all on lines where I was doing things like:

Expect.Call(viewMock.ViewState).Return(viewState).Repeat.Any()

The error was:

Overload resolution failed because no accessible 'Expect' accepts this number of arguments.  

I found a few others having the same problem

http://groups.google.com/group/RhinoMocks/browse_thread/thread/ebdfc26579f25da1

http://groups.google.com.ag/group/rhinomocks/browse_thread/thread/a85251a7ad2fae70

… but no real mention of why this was happening.

I found pretty quickly that if I fully qualified things, it would work.  For example, this works:

Rhino.Mocks.Expect.Call(viewMock.ViewState).Return(viewState).Repeat.Any()

But I was already importing Rhino.Mocks so why the problem?

 

As it is, the error is that the compiler is trying to call an extension method named “Expect”.  This method extends the class Rhino.Mocks.RhinoMocks and is defined in Rhino.Mocks.RhinoMocksExtensions.  The “Expect” that I actually want is a class defined in Rhino.Mocks that has a static/shared method “Call”.

So why is the extension method of RhinoMocks getting picked up?  I think it’s a combination of 2 different things that are happening here.  The first issue (I think) is that VB.Net does not support a static class.  Extension methods are defined in static classes in C# and in modules in VB.Net.  A module is kinda like a static class, except for a big difference: you don’t have to qualify the methods in a module by using the module name.

In other words if you have this in VB.Net

Module MyMod
    Public Sub DoSomething()
    End Sub
End Module

Class NotReallyStatic
    Public Shared Sub DoThis()
    End Sub
End Class

The way you would call the 2 methods is:

'*** Call DoSomething on the module
DoSomething()

'*** Call DoThis on NotReallyStatic
NotReallyStatic.DoThis()

So because VB treates the Static Class RhinoMockExtensions as a Module all the extension methods become in scope without any qualification, so you end up with a name collision on Expects.

The seconde issue is that the Expects extension method in Rhino Mocks is extending generic classes (e.g. T) where T is any class.  If the extension was happening on any concrete class, I don’t think we’d see this issue, but because it is ANY class, the VB compiler this it could apply anywhere inside any of your classes.  And remember, even if you DO require some concrete class for the extension,

Here’s an example of this.

Let’s say your extension methods are defined like this:

Public Module SomeClassExtensions
     <Runtime.CompilerServices.Extension()> _
     Public Sub ExtensionMethod(Of T As Class)(ByVal o As T, ByVal str As String)
         Console.WriteLine("")
     End Sub

     <Runtime.CompilerServices.Extension()> _
     Public Sub ExtensionMethodString(ByVal o As String, ByVal str As String)
         Console.WriteLine("")
     End Sub
 End Module

Note that the first uses a generic class and then second extends String.

Using these extension methods, basically ANYWHERE in your code (in VB) you could do the following:

'*** works
 Call ExtensionMethod("foo")
 Dim s As String
 s.ExtensionMethodString("foo")

 '*** won't work
 Call ExtensionMethodString("foo")

 '*** also works!
 Call ExtensionMethodString("foo", "bar")

You can see that we are able to call the generic extension method direct as if it were an instance method in whatever class we are currently working because (I think) the compiler is treating Me (or this in C#) as T, and the method is in scope because it is defined in a Module and not a Static Class as it would be in C#. 

We can’t directly call ExtensionMethodString because the class I am currently in does not inherit from String.  But, you’ll see at the end, because of the whole “Module vs Static Class” scope thing, we can still call the ExtensionMethodString directly but we have to pass in a string for the first parameter, which is supposed to be the parameter that tells the compiler what type of class to extend.

So the rule here is, if you have a Class Name (or really anything) and Extension Method Name that have the same name and are in the same namespace, you can run into this problem in VB.Net, and those problems get even worse if you are extending a generic class.

As I mentioned, you can get around this by fully qualifying your calls to Expect.Call, or you could change the way you do your expectations,  but if you are writing out these types of tests and don’t want to have to fully qualify everything, then you can use an import alias like this:

Imports DoExpect = Rhino.Mocks.Expect

Then you just change your “Expect.Call” to “DoExpect.Call” and all should work!

I think this could be fixed in Rhino Mocks quite simply.  I believe all that would need to happen is that RhinoMocksExtensions would just need to move to a different namespace, like Rhino.Mocks.Extensions.  I don’t think this change would even require additional changes to the Rhino Mocks codebase, but I’m not 100% sure on that.

 

SQL Server Unique Constraint

In SQL Server you can create a UNIQUE constraint on a field that is not the primary key.  The “CLUSTERED” keyword must be removed if you already have a clustered index on the table.  Here are some examples of a 1 column and 2 column unique constraint:


ALTER TABLE [dbo].[item_orders2] ADD CONSTRAINT
UNIQUE_Table2 UNIQUE CLUSTERED
(
order_id
) ON [PRIMARY]


ALTER TABLE [dbo].[item_orders3] ADD CONSTRAINT
UNIQUE_Table3 UNIQUE CLUSTERED
(
order_id,
item_id
) ON [PRIMARY]

 

TF26177: The field System.RelatedLinkCount cannot be renamed

I have been trying to work with the TeamReview tool for code reviews.

Problem was, when I tried to install the Work Item templates associated with the code review items, I would get the error:

TF212018: Work item tracking schema validation error: TF26177: The field System.RelatedLinkCount cannot be renamed from 'RelatedLinkCount' to 'Related Link Count'.

So what’s a guy to do?  Turn to google of course.

After some research it becomes clear that between TFS 2008 and 2010 RelatedLinkCount was renamed “Related Link Count” and this was causing the problems.  It’s likely a result of having upgraded our TFS installation from 08 to 2010 instead of doing a fresh install.

After some work I found that I could resolve the problem by renaming the offending bit of XML in the file I was trying to import.  After changing Related Link Count to RelatedLinkCount and running the import again it gave me a few other items (1 after another) that I needed to correct:

IterationId

ExternalLinkCount

HyperLinkCount

AttachedFileCount

AreaId

After fixing all of these the import was successful and everything seems to be working fine.

Here is the XML file with my changes that successfully imported:

UPDATE: I somehow had uploaded the wrong file.  I believe this is actually the one I used successfully: CodeItemenCDMFixed.xml (19.02 KB)

UPDATE 2: Ok I’m stupid.  The confusion worked like this: I downloaded the 2010 version and tried to install on a 2010 server that had been upgraded from 2008.  Had problems.  Made a file to fix it.  Then later tried to install a fresh download from codeplex to a new TFS server, ran into similar problems, but really they were the reverse of what I experienced before (needed remove spaces from words vs needing to add spaces).  Turns out I had downloaded the 2008 version that time.  Totally stupid.

So, if you are trying to install to 2010 and you are getting problems like above, I think using this file will fix your issues:

Code Item en CDM.xml

if not, maybe try this one:

CodeItemenCDMFixed.xml (19.02 KB)

Update 9/25/12: Fixed the URLs to the files above.