Lighthouse for additional content#
I've been looking for a lightbox plugin type script library that deals with more than just images.  Flash/Video or IFrame would be idea.

I've found a few options like:

PrettyPhoto

Graybox

But none of these are smart enough to automatically resize an iframe to remove scroll bars.

Maybe I'll try to write that part myself.

Categories: Programming
Wednesday, September 08, 2010 8:43:27 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

ASP.NET Markup Go To Definition and Snippets#

I don’t know if this is something new in VS or if it’s because I have the power tools installed, but I just realized that I can pick “Go to Definition” on an asp.net object in my code behind, like a label, or an asp.net checkbox, and instead of taking me to the vb definition of the control, it takes me to the place where the object is defined in the ASPX markup.   

And, in vs2010 if you auto complete with pressing tab 2 times when adding aspx markup items it will auto complete the entire element, not just the little bit you are typing.

 

So for example, if you type “<asp:But” and press tab you get:

 

<asp:Button

 

But if you tab again you get:

 

<asp:Button Text="text" runat="server" />

 

There are snippets included that are named things like “textbox” and “button”, so if you type “<bu” or “<hyp” and hit tab 2 times you get:

<asp:Button Text="text" runat="server" />

Or

<asp:HyperLink NavigateUrl="navigateurl" runat="server" />

 

Categories: Programming | .Net | VS.Net
Sunday, August 29, 2010 8:32:14 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Repoint Access linked tables to different connection string#

I've been looking for a way to do this for a project I'm working on.

The access app has linked tables that are on a SQL server, but it doesn't use a DSN.  Instead the connection string is somewhere unknown to the user and so repointing it (like user server1 instead of server2, or db1 instead of db2) was a major pain point.

Finally I found some code that I can use to change it.  I changed some names, but you get the idea. 

Private Sub Detail_DblClick(ByVal Cancel As Integer)
     Dim db As Database, source As String, path As String
     Dim dbsource As String, i As Integer, j As Integer

     db = DBEngine.Workspaces(0).Databases(0)

     For i = 0 To db.TableDefs.count - 1
         If db.TableDefs(i).Connect <> " " Then
             If Right(db.TableDefs(i).Connect, 15) = "DbNameHere12345" Then
                 db.TableDefs(i).Connect = db.TableDefs(i).Connect & "Updated"
                 db.TableDefs(i).RefreshLink()
             End If

         End If
     Next
 End Sub

 

Categories: Programming
Thursday, August 26, 2010 1:38:24 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Convert Spaces To Tabs For A Visual Studio Solution or Project#

I recently installed some VS.Net power tools, and 1 of the tools is something that tells you when you have a file with mixed tabs and spaces, giving you the chance to convert from one to another.

I decided to stick with Tabs (I know that spaces v. tabs is a religious war for many, but I won't go into it).  The problem is that this only happens on a file by file basis.  Furthermore, when you change the whitespace, your source controls sees that lots and lots of lines in your file have changed, making it hard to see the 1 or 2 lines that ACTUALLY changed.

I didn't find a single utility out there for converting spaces to tabs, so after some poking around I've come up with a workaround that does the trick, even if it is a bit hackish.

I created a Find/Replace regular expression that will find leading groups of 4 spaces and replace them with tabs.  The problem is: you have to run it recursively.  So if you have a spot in your code with 10 tabs of indentation, you'll need to run the find/replace 10 times in a row, which each iteration converting 1 of the groups of 4 spaces to a tab.

Each time you run the Find/Replace the count will get smaller and smaller, until finally: 0.

The basic pattern you search for is:

^{(\t)*}([ ]^4)

and you replace with:

\1\t

In this example, the ^4 means that I'm treating 4 spaces as a tab.  Change the number if you want to have 2 spaces = a tab or whatever.

Another thing you can do to make it run faster on a large project is to first try to replace large sections of spaces before replaces 4 spaces at a time.  For example, the following stuff will search for 20 spaces and replace with 5 tabs.

You search for:

^{(\t)*}([ ]^20)

and you replace with:

\1\t\t\t\t\t

This way, if you have 1 spot in your code with 60 spaces, you won't have to run the replace 15 times.

 

Categories: Code | Programming | .Net | VS.Net
Thursday, August 19, 2010 1:55:55 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

IPhone BlindType#

Pretty cool:

http://blindtype.com/

Categories: Cool
Friday, July 23, 2010 11:11:25 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Facebook isn't even trying anymore are they#

WOW!

 

Categories: Misc
Wednesday, July 14, 2010 9:27:33 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

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.

Categories: Misc
Monday, July 12, 2010 3:45:05 PM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

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.

Categories: Networking | Firewall
Sunday, July 11, 2010 8:27:59 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Manual Testing and Coded UI Testing#

Here is the video from a session I attended on Manual and Automated Coded UI Testing. 

http://www.msteched.com/2010/NorthAmerica/DEV309

It was really impressive and interesting.

Categories:
Wednesday, July 07, 2010 11:04:11 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

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.

 

 

Categories:
Monday, July 05, 2010 6:14:47 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

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.

 

Categories: Programming | .Net | .Net Framework | VB.Net
Sunday, July 04, 2010 8:35:46 PM (Central Daylight Time, UTC-05:00) #    Comments [3]  | 

 

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]

 

Categories: Programming | Database | SQL Server
Sunday, July 04, 2010 6:12:07 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

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:

http://chrismay.org/content/binary/Code%20Item%20en%20CDM.xml

if not, maybe try this one:

CodeItemenCDMFixed.xml (19.02 KB)

 

Categories: Programming | TFS
Sunday, July 04, 2010 5:51:21 PM (Central Daylight Time, UTC-05:00) #    Comments [3]  | 

 

NDepend Resources#

I'm in the process of working with NDepend for the purpose of evaluating it when it comes to code metrics and helping with visualizing dependencies to help find areas where we could be combining assemblies into a single assembly.

To better understand the metrics I found these 3 resources on the NDepend website quite helpful:

A set of Power Point Slides in English freely re-usable for any NDepend presentation

A poster representative of NDepend Code Metrics made by Scott Hanselman, Patrick Cauldwell and Stuart Cellarier

Metrics Cheat Sheet byFrank-Leonardo Quednau

 

Categories: Programming | .Net | .Net Framework
Monday, June 21, 2010 10:12:37 AM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

Visual Studio 2010 Not Copying DLL References#

I had this issue recently when looking at someone elses solution.

Project A had a reference to project B, but when you tried to compile it would fail on Project A (because it couldn't find any of the classes in project B) and the assembly for project B would not be copied to the BIN of Project A!

The errors looked like this:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3253: The referenced assembly "MyAssemblyName" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

After a lot of messing around it turned out that the "Target Framework" for Project A had been changed to ".NET 4.0 Client Profile" instead of just plain old ".NET 4.0".

Change it back and rebuild: it's that simple.

 

 

Categories: Programming | .Net | .Net Framework
Sunday, June 20, 2010 11:04:13 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

List of .Net Dependency Injection Containers#

From Scott Hanselman:

http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx

I'm considering trying out PicoContainer which happens to be developed by Atlassian, a company I had been researching recently regarding their "20% Time" implementation.

 

Categories: Programming | .Net | .Net Framework
Friday, June 11, 2010 5:09:48 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

VS and TFS 2010 Power Tools and Free Addins#

Here are some of the tools/addins I'm using/trying with VS 2010:

CodeRush Xpress

Power Commands for VS 2010

TFS Power Tools April 2010

VS 2010 Pro Power Tools

Categories: Programming | .Net | VS.Net | TFS
Friday, June 11, 2010 5:06:16 PM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Still Having TFS Merge Problems#

I've tried baseless merges, forced merges, regular merges.... nothing ever "takes" (even though the changes TO get committed, TFS keeps thinking there are unresolved changes that need to be merged next time I do a merge).

Here are some screen shots of the crazy merges I'm trying with the 2 issues that never resolve.  Click for bigger picture:



UPDATE: I think we've resolved the problem.  There was a nonexistant file that had a mystery pending change that would never get resolved.  I undeleted it, merged this change into the file, then deleted it again, and merged that change doing a baseless merge, and it seemed to go away.

Categories: Programming | TFS
Thursday, June 03, 2010 10:04:03 AM (Central Daylight Time, UTC-05:00) #    Comments [1]  | 

 

Code Review with TFS#

I've been searching for some tools to use with TFS to help with doing code reviews.

So far the options I have found that seem worth considering are:

TeamReview

Malevich

Code Collaborator

 

TeamReview looks like the option I'm going to try first.  It's supposed to be fully integrated into the IDE, but I'm not sure how the "replay review" thing will work.  It's supposed to highlight the same code that you hightlight during the review, which I guess can work, I'll see how it goes.

Malevich is a web based tool that integrates into TFS, but it's an open source project with few users, and when I see that I tend to think that it will be a major pain to get working.

Code Colaborator is something you pay per user, about 500 bucks, which is pretty darn expensive.  I'd really like to find an option that doesn't cost several thousand dollars per year.

I'll see how TeamReview goes and I'll post my thoughts here.

 

Categories: Programming | .Net | TFS
Monday, May 31, 2010 4:58:32 PM (Central Daylight Time, UTC-05:00) #    Comments [4]  | 

 

ASP.NET Buttons, OnClientClick, Javascript Confirm, and UpdatePanels#

I'm not sure if this problem is a case of me using a button inside an update panel (most likely) or something new with ASP.NET 4.0 (we've noticed a lot of random differences between 2.0 and 4.0 in how some controls that seem unchanged between versions are actually rendering different html).

I had a button with a JavaScript confirm message inside an update panel.  So that looked like this:

OnClientClick="return confirm('Are you sure you want to commit your current changes?');"

but no matter what you selected the button would not trigger a postback.  The rendered HTML showed why.

onclick="return confirm(&#39;Are you sure you want to commit your current changes?&#39;));
   __doPostBack(&#39;cmdCommitChanges&#39;,&#39;&#39;)"

(I wrapped that line for easier reading).

So you can see that we are never even reaching the __doPostBack that is added by asp.net because of the return statement.

To fix this, just chnage your OnClientClick to:

OnClientClick="if (!confirm('Are you sure you want to commit your current changes?')) return;"

 

Categories: Programming | .Net | ASP.Net
Friday, May 28, 2010 3:42:11 PM (Central Daylight Time, UTC-05:00) #    Comments [2]  | 

 

All content © 2010, Christopher May, Inc
Open Job Positions
On this page
Google Ads
This site
Calendar
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Archives
 Full Archives By Category
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: