Wednesday, October 31, 2012

Making VS2012 Tolerable

At first glance, I was mortified with the new VS2012, look and feel. After spending two weeks using it, I have grown to like many of the features; however, there are a couple of key things you need to do to get past the ugly UI.

First disable the capitalization of the menu names. I've been using computers and internet services, since the early 90's, TELNETTing into various MUDS. The idea that using ALL CAPS, is like screaming at someone has been beaten into my head. Let's get out the duct tape, and silence VS. There is a registry hack documented on stackoverflow.

The second thing is to install the Visual Studio 2012 Color Theme Editor. You can get this from the Extensions and Updates option in the now quiet Tools menu. This tool makes it easy to modify the colors, and has a great theme, Dark with Light Editor in it, which I have found to be rather effective. The darkness of the other windows hides a lot of the less important details helping me focus and narrow in on the editor.


Edit

The registry hack still works for VS2013. Just change the path to:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\General

Wednesday, May 30, 2012

UAC and SSRS

If you are trying to access a local SSRS be sure to run either SSMS or IE as an administrator. This is really poor that a major release of both OS and SQL latter they have still not fixed this.

You can reference here for more detailed steps and read the connect ticket. If your going to tout about building more robust software don't make me run your web browser as an admin!

The worst part of this is when you login with SSMS it gives you no warning, just everything is disabled. It wasn't until I browsed to the report manager and was greated with did it all click:

User 'domain\joeuser' does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed. 

Monday, May 7, 2012

Baby Smash!

This app must be five years old and like his brother before him, Moshe has found he loves Baby Smash!

Notice though he is smashing the wife's computer, he's not allowed to smash on mine.

Thank you Scot Hanselman again

Thursday, May 3, 2012

IE 8/9 Not Enough Space Issue

We had an interesting bug report come in today. One of our customers who is stuck using IE8, reported that the spell checker in our rich text editor was causing the browser to lock up.

We are using CKEditor with the SSL Web Spell Checker product. So first thing I did was fire up IE, and test it out. I was greeted with a Javascript error of "Not enough storage is available to complete this operation." I verify my machine has 4GB of memory, plenty of disk space, paging file etc. Everything seems fine.

So I launch into the debugger and am greeted with: this.$.createStyleSheet(h)


The lightbulb went off in my head. This page is compromised of many small user controls written in ASP.Net. Sometimes our developers will put their style blocks in the control since they are building at a component level. IE stops processing style tags after the 31st. I guess it also causes an exception to be thrown if you try and add one and your past that point.

Just one more reason, I am pushing our customers to Chrome

Monday, December 5, 2011

USPS Woes

I heard recently that the USPS is facing major cutbacks. Thinking about this led me to an idea. What if the USPS provided a pay-to send email service for every postal customer in the united states. A major problem with email today is the amount of spam, and this is in part due to the extremely low cost of sending email out.

If the USPS provided a paid email service which charged the sender, a nominal fee that is cheaper to send paper mail, and at the same time more expensive then email, I think you would find a large audience that would adopt this. Since I am neither the post master general, or a politician, I'll leave all the thousands of details alone.

Is it not time for the USPS to go green?

Saturday, December 3, 2011

SSIS Packages Loading Woes

I'm doing some work on an SSIS package, and I'm also updating the database schema it uses. The package isn't loading and VS appears to be hung. It says in the status bar that is validating the package. Is this what offline mode is for?

It's been like this for 45 minutes. Software today should detect it's in this state and then give the user to skip the validation. How long does it take to drop a column on a table with 150,208,363. I guess when you have 8 indexes where the column is included as part of a covering index it can take a while.

Especially when running on virtualized machines....darn you EC2!

Thursday, October 6, 2011

Adding a new GUID column in SSIS

I just discovered there is no way in SSIS (at least in SQL2005), to add a new column of type guid. I have found some different work arounds one of which I will share quickly.


  1. Add a new Script Component, to your data flow and set the type to transformation. 
  2. Edit the component and go to the Inputs/Outputs tab. Under the output add a new column. Make sure it has a data type of Guid (FYI, I have seen references the type is called DT_GUID; however, my version of VS is not functioning properly. My data type field is all black and when I click in it, the edit dialog closes. I set the data type by finding the output column in the xml and setting the dataType attribute to "guid".
  3. Go to the script tab and in the method add  Row.<YourColumnName>=Guid.NewGuid()

A very easy work around.

Wednesday, February 2, 2011

Reflector for free? Not no more...

Turns out that Red-gate has decided not to honor it's promise to continue to offer reflector for free. Reflector is perhaps one of the most beneficial and well used tools to help .net Framework developers. Show me a developer who doesn't know what reflector is and I'll show you a developer who is just learning .net.

Hopefully c#.next won't modify the IL it generates breaking the tool. But if it does, I guess 35 bucks isn't a lot to pay to avoid having to learn how C# maps to IL and translate it in your head.

Thursday, January 27, 2011

Ruby & Watir in Five Minutes

I have decided it was time to automate some of our web tests for a variety of reasons. If I have to convince you why to automate then your reading the wrong blog. I have choosen to use Watir (Pronounced Water). Watir is a free open source Ruby Gem.

I found getting Ruby and Watir up and running to be a fairly smooth process; however, some of the documentation on line wasn't 100% accurate. My goal is to give you the info to get up and running as quickly as possible. The information in this post applies only to Windows


Step 1 - Installing Ruby

  1. Install Ruby - I have had errors using the 1.9.X branch, things run much smoother with 1.8.7

Step 2 - Installing Watir as a Ruby Gem


  1. Open your favorite command prompt, and make sure you have the latest version of Ruby Gem's:
    gem update --system
  2. Install watir using:
    gem install watir
  3. If you want to use firefox you'll need to install this extension for Firefox 3.6


Step 3 - Your First Test Case


The directions at watir's site are very good for creating your first test case. The one important detail is before the step where you should enter require 'watir' you need to do require 'gemsystem'.

Thursday, January 20, 2011

Long time no post

It's been a very long time since I published something here. So what have I been doing? Over the last year, I have found all my time consumed, between three things, Family, Work and Facebook. I simply never had the time to write any more posts. This year I am going to make more time. How can I do that?

Well since I don't want to give up any time with my family, and I can't give up any time spent on the job, that leaves, facebook. I have blocked my access to 90% of the games that used to drain my time, and removed almost all of the non-friends friends I had. Now it's time to get my priorities aligned up right again.

Although I can't stop working, I have decided to work smarter. There are so many better ways to do the things I have been doing. I am tired of using the all the standard excuses. To that end I have started down the path of automating the testing of our web application. The application has really stabilized itself over the last year as far as functionality in various key areas, that a couple of well thought out automated test scripts should help reduce the amount of time, and effort we spend testing, and reduce the amount of bugs.

I have just started exploring Watir and hope to have some posts on it soon.

Wednesday, February 24, 2010

Ping box from Yahoo!

It had been a long time since I had used Yahoo Messenger; however, I needed to install it and use it the other day, after doing so I found something which I found cool enough to blog about: Yahoo Ping Box!

With a couple clicks I was able to embed a yahoo messenger client right inside my blog. Or on any of my other sites / social networks. It was even easier then setting up AdSense. When you enter a nickname, my yahoo client is notified that so and so user has logged in. This is a negative in my opinion, as it pops up a little toast and it doesn't indicate it's from an anonymous source.

However it does warn you when you have an open chat window that it is from an anonymous pingbox user.

Wednesday, February 3, 2010

Get with the times!

I was checking my google analytics today (which I haven't done in ages), and I noticed something that was profoundly disturbing. In the last month, roughly 3% of the readers of this blog were using IE6.

Now I have nothing against Microsoft, (obviously since if you read my blog you would realize I develop using their tools), nor am I Microsoft hater; however, as web application developer, I strongly despise everything about IE6.

If your using IE6 or IE7 go upgrade already! Or go use FireFox.

Friday, January 29, 2010

Skinning a User Control

It's been a while since my last post, and while I have many ideas for posts, I have opted to spend my hours either working or enjoying my family; however, I came across a case today which will take only a second to blog about.

ASP.Net supports skinning and themes. If you don't know what that is I suggest you go search on it. In a site I am working on we have a User Controls, which are being used as Web Parts. A new requirement came up that depending on the theme we are using we will want to change the Title of the web part. So I fire up Visual Studio, and first thing was to add a new item to my skin file:

Navigating to the page resulted in the YSD (Yellow Screen of Death) with an error indicating that myControl couldn't be themed. The next step was to go and add a Themable attribute on the properties in the control I want to skin. You also need to add Themable to the class as well so you end up with:

[Themable(true)]
public class myControl : System.Web.UI.UserControl
{
     [Themable(true)]
     public string Title {get;set;}
}

At this point you can not skin your user controls. One thing I did skip is to make sure the skin knows about the user control. You can do this by registering it in the web.config by adding a record to the Pages\Controls section as follows:
 

You can also register it on the skin using the following declaration:

<%@ Register TagPrefix="myComp" TagName="myControl" src="~/Controls/MyControl.ascx" %>

Wednesday, October 14, 2009

Google & MVPs

For those who don't know who Jon Skeet is, he is an excellent contributor to the C# community, through his daily answering of questions on Stack Overflow, to his many excellent articles and books. Jon recently posted that his employer has asked him to turn down the MVP reward for this year.

What employer wouldn't want their employees to be recognized as community leaders in Microsoft Technologies? Google for one, as they are Jon's current employer. Jon won't comment on why this is so it leaves us to speculate what the reasons might be. Even if there is a sensible reason for this the silence lets myself feel that this is due to the competition between the two companies. That has definitely soured my opinion about Google and its Management team.

Thursday, October 1, 2009

Just trust me!!

Today I was working with my intern, we are using DotNetNuke to run a marketing site so that our product team can go in and tweak some things. We have custom workflow in there, and a requirement that we want to save the results of the workflow into our own table so we can report on it latter.

The workflow component has some facilities to do this, so he creates a table and a stored proc, and gives it a shot. He is instantly greated with a lovely error in the front end Invalid Syntax Near xyz

I tell him that's not good, as it indicates a potential for a Sql injection attack. Fast forward three hours, and he is arguing with me that its safe, that it can't be injected, and demands I prove to him it can be done.

Not wanting to take the time or effort to figure out the magic sequence, as this isn't something I do everyday (Contrary to popular belief, I don't sit around trying to hack). I tell him to trust me, parsing errors are easy to inject into. He doesn't buy it, and I can see he is going to be stubborn until I prove him wrong.

Fast forward ten minutes, and I found that injecting with this forms component was as simple as entering a string like the following for the last field:

injectComing' select * from aspnet_users--
Watching with profiler, we quickly saw three key events. First was a Batch Starting which looked something like this:
exec myProc '','','','injectComing' select*from aspnet_users--';
Second was SQL Stmt Starting Event:
exec myProc '','','','injectComing'
Third was another Sql Stmt Starting Event:
select*from aspnet_users--';
Needless to say now he is working on a costume module so we can execute the Sql as a parameterized query and avoid all this ass ache. Moral of the story? While you shouldn't always trust everyone, you should trust your boss who has 10 more years of experience. And if you don't you try and prove him wrong, don't demand your boss to prove himself.


Gahh Interns!

Saturday, September 26, 2009

Responsability of Third Party Control & Blacklists

My intern just sent me a screen shot of a CAPTCHA from a site we are working. The CAPTCHA is generated by a third party control which we have no control over.





If you are a developer of third party controls which are sold to professional companies please take the effort to implement a blacklist of letter sequences that should not be allowed in CAPTCHAs. What are the odds of this happening probally preety small but had we lost a sale because of this....

Tuesday, September 8, 2009

Telerik Gives Back to the Community

While using StackOverflow a great site for asking questions to problems software developers face, I noticed an advertisment from Telerik. They have decided to give any SO user who has over 10,000 reputation points a free developers license to their control suite.

This is great to see a company see the value a site such as Stackoverflow provides, and to provide some recognition to the people who spend their time helping others by answering questions. Thanks again!

Wednesday, August 26, 2009

Duration in RPC:Completed is Misleading

I discovered something today while troubleshooting a long running query today. We have a specific dialog in our application which in a specific case takes 60 seconds to open up. I fire up SQL Profiler and click run just to see the standard events and verify if this a DB issue or not.

I find that there is a specific query which does take 60 seconds to run according to the RPC:Completed event (We are using SQL Server 2005). So I pull that query out and run it inside of SSMS, it completes in under a second. These are the issues I hate having to troubleshoot. So the first thing was to rule out our web application, so I create a little .net windows form app and I basically run this:


sqlCmd.Connection.Open();
using (var reader = sqlCmd.ExecuteReader())
{
    int i = 0;
    while (reader.Read())
    {
        i++;
    }

    MessageBox.Show(i.ToString());
}



The query runs fine no issue. Now we are actually using nHibernate so I wanted to simulate us processing the result set. I add a small Thread.Sleep(5) (my result set has 1500 items in it so a small sleep duration is plenty). I run the query and wait about eight seconds.

Then I go and look at SQL Profiler RPC:Completed (And Stmt:Completed events). The duration for the events is 8 seconds. Now I am asking myself if I opened a ticket with Microsoft burned a support incident for an nHibernate issue or not.

The moral of the story? Well don't always trust what you think the tool is measuring. And if your interested, when I ran my queries loading the entities through nHibernate with the windows form, the query again completed extremly fast. So I am still hunting this one down.

Update

I found and resolved the issue. It wasn't an issue with SQL but a configuration issue which caused the system to try and log to an invalid file thousands of times which slowed the system down.

This is very eye-opening as one of my fundamental assumptions about SQL Profiler and how to interpret the results has been crushed.

Tuesday, July 14, 2009

Turning off ASP.Net's Unique ID Generation

One of the things I am not a fan of (but I understand why they have it), is the unique id generation for server side controls in ASP.Net. The unique Id generation allows the framework to ensure that all controls will have a unique client Id, allowing it avoid collisions.

While this is great it does add a lot of complexity as you start to move away from the traditional ASP.Net Web Forms model. This complexity is one of the reasons this feature doesn't exist in ASP.Net MVC. What are some of the issues with the unique id generation?

  • If you have javascript in your pages the controls are given a somewhat dynamic name, this leaves you with two options. Either you dynamically generate your javascript, or you can assume that you won't be moving the control, and can hard code the ID. The ID is based upon a concept of Naming Containers which is beyond the scope of this post. But essentially as long as you don't introduce new containers in the hierarchy the Id will always be the same.
  • If you want to use post a form to a non-web form page(or different page then the generating page), and want to make use form fields, the field names are associated to their unique id.

The first issue I have always solved by either generating the javascript dynamically in my user controls for example (A user control acts as a naming container and thus all controls in the user control will have it's unique id based on the user control's id). Or by just hard coding the value and hopping I don't change it.

During my latest round of enhancements to my current project I ran into a scenario where I felt I had to disable this unique id generation and couldn't find a workaround that didn't involve rewriting a ton of code. Let me give you some background on the scenario.

This site deals with types of documents, and allows the user to printout (or Email) various PDF files based on the document. There are currently roughly a dozen various printouts and emails which are generated, and the number is always growing. In order to streamline my code and simplify adding new types of printouts, I created a method of doing this which essentially is as follows:

  • On the document's details page we have a second form, this form contains all the printing and email options. There are quite a few variations of options, and certain options depend on other options being set.
  • We preserve the last options used to printout the document, which are set at render time for the page.
  • The form is smart enough to know which type of printout it is doing and will either open a new window, or reuse the current window when doing a post.
  • This form posts to an ASP.Net Handler which based on the type of printout directs the request to what I call a print handler. The print handler will either execute (if its sending an email for example), or it might render a new page to let the user see a preview, or it might just generate a PDF for the user.
  • When generating PDF's we generate the Html and then use a third party tool to convert it to Html.

It's actually a pretty slick mechanism and has streamlined a lot of the code. My new requirement is to enable printing from other pages then the Details page. At this point I have two choices. I can either duplicate a subset of my code to allow printing for just document types we need, or I can try and find a way to consolidate this printing framework to make it reusable.

I opted for the second option of course. So the first thing was to move all the markup, script and code behind outside of the details page into its own user control. A quick test showed that some basic functionality is there so I dropped the control onto my new page and things were looking good. This might be possible I thought.

Then I started doing a deeper more thorough testing (And I wish I had an automated unit test for this UI stuff but ah well It's on my ever growing to do list). I quickly found that all the Id's had changed, this messed with all the javscript which enables or disabled options based on what you've selected.

Well we can fix this one easily so I pick one of the controls, and modify the javascript so it is dynamically generated, and things are looking good again. So then I go and printout the most complex of the documents, this time paying close attention to it, and I noticed that none of the options that were set, were being honored.

The issue is the form fields changed so in the old version I was expecting to see a field with id of "printDescription" now it's coming out as "printOptions_printDescription". Furthermore when I drop it into a content page, which happens to user a master page which is also nested, the Id becomes a long mess. So now at this point how can I tell ASP.Net to not auto generate the Id's. I could write my own custom server side controls but that's a lot of work. I could get rid of the server side setting of options but to do that I would now have to either generate all the html dynamically, use code in the markup, or make a second call to get an json representation of the print options and set them on the client.

So let's get back to the original point of this post. I am going to turn off the Unique ID Generation. The first thing is this works if you have a naming container, which you can override properties on. A user control works perfectly, and since a user control doesnt render any markup by default it doesn't change the structure of the page.

I have found that by overriding the following properties results in the control's child control's from picking up the containers uniqueid and appending it.

    public override string UniqueID
    {
        get { return ""; }
    }

    public override Control NamingContainer
    {
        get { return null;}
    }


Caution


I have not tested this beyond my simple usage scenario. I do not know what would happen if these controls were used in a normal postback scenario, if they would be able to pickup their state from the form fields or not.

Wednesday, June 24, 2009

I need a vacation

So this morning I was thinking about some basic things we can do to speed up the download of our pages, including combining and minifying our JS / CSS files. I decided to go look at YuiCompressor, which is a minifier from Yahoo.

I think to myself neat let me bookmark that and come back to it.



I guess I had this same thought the last time I thought about the subject. Ugh!!!