Blog

SSMS and the IntelliSense Red Squiggle Mess

February 21, 2014 by Mark Dickson

Have you ever been writing a bunch of SQL code in SQL Server Management Studio (SSMS), only to have the query editor put a red, squiggly line underneath a table, column, view, procedure or any other object that you know exists? Of course, that red, squiggly line means that IntelliSense is not recognizing that object, thus it will also not appear in your auto-complete pop-ups either. If you too have come across this, it is likely that the object has been newly created or modified since you last opened SSMS.

I have known about this issue for years, but have just ignored it up to now. Luckily for us, there is a simple solution. Though I try not to rely on IntelliSense anyways, I decided to take to Google and see if I could figure out how to fix this problem without restarting SSMS. The answer lies in the cache.

YES, IT DOES EXIST, YOU LITTLE…!

The other day I created a new table in my database. I ran the script, checked in the Object Explorer to make sure it was created properly, then started writing Stored Procedures against it. It became quickly apparent that IntelliSense was not recognizing my table, as illustrated below:

Figure 1: Bad Code Before Refresh Figure 1: Bad Code Before Refresh

My scripts would still run and execute fine, as the table did actually exist, but IntelliSense can make it easy to double-check yourself when writing code. Recognizing that it was an IntelliSense issue, I searched for solutions.

Read More »

Visual Studio Extensions Update Hell

January 31, 2014 by Damien White

This post is a rant about the Visual Studio Extension update process. It’s one of those things that I think we all get annoyed with, right? Well, maybe it’s just me. Anyway, let’s look at how the Extension update experience in Visual Studio can be fixed.

Let me start by apologizing to Microsoft and the Visual Studio team, I’ve gotten to the point of being fed up with the process so I found it therapeutic to rant about the experience. My goal here is to improve the software that I use day in and day out.

Begin Rant

First off, in a world of “Automatic Updates” and “Upgrade All” buttons, why aren’t there similar options when updating VS extensions? Having to click each item in the Upgrade list and go through two or three windows to have the update installed is annoying. One fix here would be a list where you could “check” the updates you wanted to install, and then click once to have them all installed.

As you’ll see in the next section that describes the current process, those annoying windows are modal, meaning you can’t do anything with Visual Studio until the extensions are installed, and you can’t even use the extensions until restarting Visual Studio. What a way to kill productivity. Grrrrr…</p>

Read More »

Windows Search Doesn’t Like Android File Import

January 24, 2014 by Mark Dickson

Have you ever remembered an important file on a mobile device, such as your smartphone, that you forgot to backup? Have you then gone looking for that file only to find that it doesn’t exist in the location you expected it to be? If so, I am guessing this realization is followed by a certain degree of heart-sinking, nauseating panic, which comes along with the immediate dropping of all other tasks around you to frantically look through the files. You start to wonder, “did I put it somewhere else,” “did I back it up already” or “I am going to write a scathing letter to the makers of my storage device for making a product that will just lose my data.”

If you have been here, I feel your pain. The other day I thought I had lost an important video on my phone. After frantically looking through the photo and video albums in my QuickPic app to no avail, I hooked my phone up to my PC with USB to search through the files directly. I could have done this with my Astro File Manager app but I figured this would be easier so I could copy it onto my computer when I found it.

The main problem I ran into was trying to copy the files from the Search Results View in Windows Explorer to my local hard drive. Rather than copying correctly, a cryptic error window popped up. I initially freaked out thinking that my files were corrupt, which might have caused them to be lost in the first place. After a quick Google search I found that this is apparently a known issue with this operation. I will share my story.

I should let you know that the phone I am working with is a Samsung Galaxy S3 using the stock Verizon Android OS (ver 4.1.2), connected to my machine running Windows 7 Professional SP1. iPhone users should stop reading here. I am not sure how iTunes handles files, searching and syncing for your iPhones and iPods, but I don’t get involved in that mess.

I was not too familiar with the new method of Windows file searching brought about in Vista. Microsoft has moved to injecting search options and “hints” into the search string directly, which is hidden as a small text box in the upper right of the explorer window. When in the explorer window, the search box will default search the current location and sub-folders. I won’t spend my time teaching about Windows Search, you can learn how to Find what you’re looking for, including How to Use Windows 7′s Advanced Search Operators and also check out some Advanced Tips for Windows Searching out there on the web.

Tweaking the Way Windows 7 Searches

Having figured out and tested some of the Windows 7 search options, I selected my connected phone and searched for some files that I knew existed. I was less than surprised to find that Windows searched for a few seconds and brought back a subset of the files that I knew should be returned from the search. Ah, Windows file indexing, thou art a pain in the butt. Back to my friend Mr. Google to figure out how to change this.

There are a few options I found in this article How to Make Windows 7 Search File Contents. It is possible to add certain folders and locations to the Windows Index, but since this device is not usually connected, I opted to change my search options using Method #1: Enable Widespread Content Searching. Granted this method does not technically address my problem as Windows should have still searched my non-indexed location by filename (by default settings), but I have often found Windows Search to be unreliable.

Read More »

New Blog Author Says “Hello World”

January 17, 2014 by Mark Dickson

Hi there! Je m’appelle… I mean… My name is Mark, (“Hi Mark,” says the crowd). I am a professional software developer specializing in web applications, but who isn’t these days, right? Damien has been bugging me to start blogging my experiences for a while now. I finally gave in. Since I have been through my fair share of “gotchas” and nuances while programming, I figure it is about time I start sharing these experiences with others. If each blog post I write helps at least one other person, then I feel it is absolutely worth it.

The Apple™ That Started It All

Alright, here is where the boring “How I got started” stories come into play. You don’t have to read this, just skip to the interesting stuff.

I first started writing code when I was about 8 years old. My friend had an Apple computer with BASIC on it and we (somehow) learned how to use it in its most rudimentary sense. Mind you, this was back around 1991 when it was still pretty cutting edge and we didn’t have the Internet at our disposal for BASIC research. I still remember how much mischievous joy it gave us when we first wrote the following:

10 PRINT "Hahaha! You can't stop us now!"
20 GOTO 10

We thought we were so clever. Surely no one else was smart enough to do that! We just knew that when someone “accidentally” ran our program, it was sure to halt their whole computer and create an inescapable loop of total destruction, MUWHAHAHAHAH!!! Thankfully, that never came to fruition, and even when we persuaded our fathers to run the program, they bested us with their knowledge of the shortcut keys for the command to terminate the running program. We were foiled and humbled. Nevertheless, this started off my interest in writing software.

Read More »

ASP.NET HTTP DELETE 404 Error Fun

December 27, 2013 by Damien White

In a previous post, I discussed using the Restful Routing NuGet package with ASP.NET MVC. Well, I use it all the time when working with ASP.NET MVC. I started a new project the other day and found that the Destroy actions (which use the HTTP verb DELETE) were giving me an HTTP 404 error. A 404 error struck me as a bit odd, as the problem is often an HTTP 405 (method not allowed) when attempting to perform a DELETE in ASP.NET projects. What was especially puzzling was that I’ve used Restful Routing so many other times, what was going on with this new project?

One of These Things (Is Not Like The Other)

Ok, so why would one project work and another fail? All of them run through IIS Express, so it probably isn’t a problem there, though if you search around the web for errors relating to PUT or DELETE in .NET, you’ll find a lot of articles related to changing the applicationHost.config. Anyway, that wasn’t my problem.

I started by looking at the routes for the project. Restful Routing provides an awesome route debugger. Just adding the line map.DebugRoute("routedebug"); to your Routes.cs file (I almost wrote routes.rb there :), GO RUBY!), then you can hit /routedebug to get a handy list of your routes. Well, the route was clearly there, so that wasn’t the problem.

As a last ditch effort, I figured it had something to do with the web.config, and sure enough, I was correct. Comparing one web.config to another, I noticed that the problem. I was missing a modules section, and corrected the issue by running all the requests through .NET by simply setting runAllManagedModulesForAllRequests to true:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

If you aren’t familiar with the runAllManagedModulesForAllRequests parameter, the documentation definition is:

True if all managed modules can process all requests, even if the request was not for managed content; otherwise, false.

In other words we’re saying, “Hey IIS, hand everything off to .NET for processing.” In our case IIS was getting in the way.

Wrap Up

I didn’t try any explicit PUT requests (as I use RestfulRouting’s PutOverrideTag HTML Helper), but given that PUT and DELETE are the two “problem” HTTP verbs, this should work for PUT calls as well.

In general, I found that most of my projects have had the runAllManagedModulesForAllRequests attribute set to true. However, it seems like there should be a more elegant way to solve this problem. I did mess around with IIS a little bit, but didn’t come up with anything to fix the DELETE 404 error. I would be interested to know if any of you have found a better way to solve this problem. Given that WebAPI uses REST (why ASP.NET MVC doesn’t baffles me), it feels like there must be a better solution.

PSA: Don’t Trust Autocomplete

November 25, 2013 by Damien White

Listen Up! Autocomplete can trip you up!

Here’s a little tip that we developers all should know. This post is a little about the Kendo UI Grid, a bit about ASP.NET MVC, but more about “common sense.” So let’s get started…

Kendo UI Grid

I’m using Kendo UI’s grid for a few different ASP.NET MVC projects. If you’ve read my other Kendo UI related posts, this probably isn’t a surprise. A lot of my pages/controllers have repetition, so I have a base controller that I use for the common functionality. In the generic base controller, I have the following methods for my Index action/page:

public virtual ActionResult Index()
{
    // There is no need to query for models as we use KendoUI in Ajax
    // mode to hit the List action after the view is loaded.
    return View();
}

public virtual ActionResult List([DataSourceRequest] DataSourceRequest request)
{
    var models = GetModels<T>(_context);
    var results = models.ToDataSourceResult(request);
    return Json(results);
}

NOTE: GetModels<T>(_context) simply returns an IQueryable of the model T

This works for most of the cases, but in few nested resources, I need to filter the results on the server before calling the ToDataSourceResult. Using Visual Studio’s (or R#’s; not sure what does what anymore after using R# for so many years) override auto-completion, it generates the following:

public override ActionResult List(DataSourceRequest request)
{
    return base.List(request);
}

Not thinking much of it, I went ahead and added my revised code in the body of the method. Everything seemed fine until I tried to sort the Kendo grid. Nothing would happen. At this point, seeing the two code snippets together, you probably figured the issue. I should have caught on to it sooner, but alas, I was blinded by “it must be a Kendo UI problem.” Read More »

Dude, Where’s My DLL Config?

October 21, 2013 by Damien White

I write a lot of reusable components. Most recently, I created an assembly to handle notifications in various projects. For this assembly, I needed various configuration options, such as an SMTP server address. For configuration in .NET projects, we turn to App.config files, and in ASP.NET projects, we have the Web.config. In the case of a DLL however, it isn’t really advised to create/use an App.config file. On Stack Overflow, Chris Ammerman goes into great detail on the topic. But, hey, what if you want to use one anyway?

Attempt #1

Reading an assembly’s configuration file is pretty easy, you can access the AppSettings section by opening the configuration using the Assembly.GetExecutingAssembly().Location like so:

var dllPath = Assembly.GetExecutingAssembly().Location;
var dllConfig = ConfigurationManager.OpenExeConfiguration(dllPath);

// Get the appSettings section
var appSettings = (AppSettingsSection) dllConfig.GetSection("appSettings");
return appSettings.Settings;

That’s as easy as it is; or is it? This method works fine if you’re using the DLL in a Windows or console application, but try using it in an ASP.NET/ASP.NET MVC application, and you’ll find that Assembly.GetExecutingAssembly().Location points to something like C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\blah\blah\blah (the ASP.NET shadow copy directory). Navigate to that directory, and you won’t find your config file there. One solution could be to copy the file to the temp directory, but that isn’t going to work in the long term. There has to be a better solution! Read More »

One Off Overrides of ajaxStart

August 29, 2013 by Damien White

As I’m sure you guessed from earlier posts, I’m using BlockUI in an MVC application. I have various calls using jQuery’s $.ajax method throughout my application. For the majority, I want to show a “Please Wait” message, and BlockUI makes this simple. Since most of my calls need that functionality, I simply use the following:

$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);

Greedy == Problems

The greedy approach works just fine until you have a call where you don’t want to use BlockUI. For example, in my application I have various forms inside modal windows, which block the background already. While the user is interacting with the form, I make various Ajax calls to get additional data or to perform remote validation. Every time I make a call, the user ends up seeing a flash on the screen because the background of the modal window (which is transparent black) ends up getting stacked with the background of BlockUI (also transparent black). Not a great experience. It reminds me of the early days of the web with flashing and flickering tricks that you’d see on many sites. Besides aesthetics, it is just confusing for the user.

Options

What are the solutions? Well, you could use BlockUI “manually” by calling $.blockUI() when you want to block the page and then calling $.unblockUI() in a callback to, well, unblock the page. That’s not always an easy pattern to follow. If you are using 3rd party components that make $.ajax calls internally and you want to block the page, then the ajaxStart/ajaxStop approach may be easiest. Also, if ~95% of your calls need the functionality, why specify it everywhere? Thankfully, there is a way to have your cake and eat it too.

Solution

If you head over to the jQuery docs for ajaxStart, you’ll find the solution in the Additional Notes section:

If $.ajax() or $.ajaxSetup() is called with the global option set to false, the ajaxStart() method will not fire.

W00t! That’s a simple solution for our issue, and in my testing, it works perfectly. Just set global: false and now there’s no more weird background flickering.

During my search for the answer, I came across another technique that works as well. This solution may be preferred if you have other things that happen during the ajaxStart event.

RubyMotion and Lowercase Obj-C Libraries

July 23, 2013 by Damien White

Rubymotion Logo

I was playing around with RubyMotion and the Objective-C iHasApp library. Given that it’s just three files that are needed (a .m, a .h, and a JSON data file) I’d figured I’d have it working in no time. I was wrong.

iHasApp: Undefined

My first attempt involved me copying the three files to a vendor/iHasApp directory inside my app. Then, in my Rakefile I added the line:

app.vendor_project 'vendor/iHasApp', :static

Well, that was easy! Let’s run the app. Whoops!

... undefined local variable or method `iHasApp' for <MyController:0x9607730> (NameError)

Everything looked fine in my app as I had a properly generated .bridgesupport file. Hmmm, what was it?

I figured that my problem could have been due to there not being an .a file (SPOILER ALERT: it wasn’t :)).

I then went on to try using the CocoaPod, using motion-cocoapods, but it yielded the same result.

Searching and Searching

So off to Google I went, searching and searching. I couldn’t figure out what was wrong. Pretty frustrating. In the end I wasn’t searching for the right thing. Thankfully I stumbled upon an answer by Laurent Sansonetti on the RubyMotion Google Group. DUH! “The problem is that the iSpeechSDK class name starts with a lower-case letter, which is not a valid constant name in Ruby.” This same thing applies to iHasApp, doesn’t it? The fix is simple, just use IHasApp.alloc.init instead of iHasApp.alloc.init. Super easy fix (and obvious), but finding the answer was quite a challenge.

Kendo UI NumericTextBox With jQuery Validation

June 27, 2013 by Damien White

<img class=”alignright” title=​”kendo-logo” alt=​”Kendo UI Logo” src=”http://visoftblog.visoftinc.netdna-cdn.com/wp-content/uploads/2013/01/kendo-logo.png” />

Previously we discussed Kendo UI and the problems with jQuery validation relating to the Kendo UI Editor. Well, I discovered another control that exhibits the same problems, the Kendo UI NumericTextBox. I didn’t think that this control would have the same problem as the Kendo UI Editor, after all, it’s a text box. Alas, I was wrong. It is quite annoying when you find your form submit (at least the validation happens on the server). What’s going on?!?

Problem

If you didn’t read the earlier post, the problem is that Kendo UI may hide your actual input, “overlaying” its own, depending on the control. Your input element has the validation attributes needed for jQuery Validation, but because it’s hidden by Kendo, the client-side validation doesn’t fire. You can read more about this in the jQuery Validation 1.9.0 release notes, where it started ignoring hidden inputs.

Solution

If you read my earlier post, or you figured this out on your own, you are probably aware some of workarounds. One approach is to have jQuery include all the hidden inputs on a page (a.k.a “the greedy approach”). In this case, you won’t fall victim to this issue. Here’s that approach again:

$.validator.setDefaults({ ignore: []});

I’m not that big of a fan of greedy approaches for things like this; they can cause unexpected bugs to occur. Instead let’s target the Kendo UI Numeric Textbox control directly (well, the input element inside of it).

$("form").data("validator").settings.ignore = ":hidden:not(.k-numerictextbox input)"

We should be able to build on the ignore string from my last post on the topic, including both the Kendo UI Editor and the Numeric Textbox controls:

$("form").data("validator").settings.ignore = ":hidden:not(.kendo-editor textarea, .k-numerictextbox input)"

If you recall, my Kendo UI Editor field happens to be wrapped in an element with a class of kendo-editor, though you can use any option that works for you.

I wonder what other controls have the same problem. Any guesses, thoughts, or comments?