A Blog by Scott Isaacs

Tag: Development Page 1 of 6

NuGet and Lowering .NET Framework Version

Background

Today I was about to deploy an app to the server when I realized I had been building against .NET 4.5 while the server only had .NET 4.0 on it.  

Not a big deal, right?  I just needed to change the “Target Framework” in the project properties.  So I did, and it wouldn’t build.  Turns out I had some NuGet references that were targetting .NET 4.5.

Again, no big deal.  Remove EF 5.0 and add EF 4.4 (which is conspicuously named EF 5).  My build succeeds and gets deployed to the development server.

But it won’t run.  I dig around and find other NuGet references (specifically, Newtonsoft.Json) that also are targetting the wrong framework version.  I uninstall and re-install it (and Web API Client and HttpClient).

The Error

But at this point, my solution doesn’t even build.  I kept getting an error message:

‘System.Net.Http.HttpContent’ does not contain a definition for ‘ReadAsAsync’ and no extension method ‘ReadAsAsync’ accepting a first argument of type ‘System.Net.Http.HttpContent’ could be found (are you missing a using directive or an assembly reference?)

But I have a reference to System.Net.Http.Formatting where that extension method is defined.  In fact, when I use Visual Studio’s Go To Definition function, it takes me right to the definition.  At this point I’m perplexed.  So I do what any other developer would do.  Repeatedly remove and re-add the NuGet references, trying to figure out why it won’t build.

The Fix

All in all, I probably wasted almost three hours on this today before I found the fix.  I had to comment out the line of code that had errors and build the solution.  Once I had a solution that successfully built, I uncommented the line and the solution built successfully.

I don’t know why this fixed the issue.  I could spend more time trying to figure out why, but frankly, at this point, I don’t care.  I’m just glad I got my app deployed to the dev and test servers today and that I finally get to work on the project I planned to start last week.

On Visual Studio Project Templates

If the Blank App template were a sheet of white printer paper, the Navigation App template would be a sheet of graph paper — both are essentially empty, but one provides some helpful structure. By contrast, the Grid App or Split App templates might be pages from a coloring book, where the outline of your application is provided and only the details must be filled in.

(from my upcoming book)

Issues Debugging Windows Store apps in the Simulator

Debugging Windows Store apps in the Simulator is a pretty slick idea that mostly works.

Mostly.

A limitation of the Simulator is that it runs as a child session of the current user session.  This short straightforward answer on Stack Overflow explains.

The problem with that for me is three-fold.  The first is just annoying: any apps that I have that run on system startup are launched when the simulator starts.  Some of these apps have problems with running multiple instances as the same user.  I imagine that they try to lock some resource (a file, etc.), but since that is already locked, I get a lot of error dialogs in the Simulator.  I get around this using a script I wrote to kill the offending processes in the child session.  It’s annoying, but I can work around it.

A second problem is that my user has permissions that another user might not have.  I do run Visual Studio as local administrator (disclaimer: I know the arguments against this), but that’s not entirely what I’m talking about.  Network resource permissions and other such differences could also cause issues.

Selfishly, I have a third issue that would be solved by allowing the Simulator to run as a different user.  I take a lot of screenshots.  When I want to take a screenshot of my Start screen for use in some documentation, or my upcoming book, I don’t necessarily want all of my apps/tiles in the screenshot.  I’m not so worried about people seeing what I’ve got going on, although no one really needs to know my next appointment, latest email subject line or recent tweets that are displayed on the tiles.  The bigger concern is that those tiles add clutter that could distract and/or confuse the person that will be reading my documentation.  

One possible solution is to use Visual Studio’s Remote Debugging functionality to connect to a virtual machine running, described in the previously mentioned Stack Overflow answer.  This goes a long way to eliminate the issues I’ve raised, but it has one drawback.  I can no longer use the Simulator tools such as spoofing geo-location or touch mode or easy way to change screen resolutions.

My current solution is to continue to use the Simulator as it is.  When I first launch it, I switch to the desktop and run my utility to kill any processes that cause errors with multiple instances.  This is where I do my primary testing and documentation.  When I need more isolated testing, then I use Remote Debugging to debug on my Surface RT.  This is probably the most correct way of debugging but does require me to have both my laptop and Surface running at the same time.

All in all, debugging Windows Store apps is a good experience, but a few changes to the Simulator could make it nearly perfect.

If you’ve run into similar issues debugging Windows Store apps, what have you done to fix or work around them?

Beginning Windows 8 Development (book)

You may or may not know that I am currently writing a book.  If you didn’t, now you do.  That’s a picture of the cover.

It’s a book about writing software for Windows 8 using HTML and JavaScript.  The first few chapters are heavily based on a similar book which introduces building Windows 8 applications with C#.  I’m really excited about it, and it should be available by the end of summer.  I’m not done yet, and I have a fair amount more work to go, but it’s getting there.  

A few weeks ago, the publisher, Apress, made an alpha version of the book available on their site.  Buying the alpha version gives you access to draft versions of the chapters I am writing as I submit them, even before the editing process has been completed.  Then I found out earlier this week that you can also pre-order the book on Amazon.  I thought that was pretty cool, and it’s kind of a boost to the ego to see that, not to mention adding motivation to complete the process.

Imagine my surprise today, though, to come across this advertisement “in the wild” when checking the weekend weather.

Event Timer – Windows Store App

Update 5/4/2013: Source code now available on GitHub.  

Download Event Timer from the Windows Store I just spent a couple hours writing a Windows Store application for use at our Deeper in .NET conference this weekend.  It’s a simple app that displays the time remaining until the next session starts, and also allows you to cycle through slides (image files only) during the countdown.  Event Timer was initially published on 4/4/13.  You can find it and screenshots in the Windows Store.  For now, and for the foreseeable future, it will be free.

I already know of a few feature improvements I’d like to add to a future release, such as:

  • Moving the controls to an app bar (done, you can now view the controls by right-clicking or swiping from the top edge)
  • Adding some configuration options that persist, such as default slide interval and foreground/background colors.
  • I have some other ideas for subsequent releases as well, but will hold off on thinking too much about those to see if anyone else asks.  Why waste my time on something no one wants, right?

If you use Windows 8 or Windows RT, please give it a try and let me know what you think.  I’d be interested in any feedback.  However, since this is a free app, support will be limited and may be slow.  While no guarantees are made about this software, I have recently used it at a large developer event in Milwaukee.  I had zero issues and actually had several attendees compliment the app.

If you are a developer and are interested in seeing the very simple source code, you can find it on GitHub. Remember, I only spent a couple hours on the initial version for my own use, so be kind.  đź™‚

Visual Studio Command Prompt Here

I’m rebuilding my computer after a hard drive failure, and I keep running into issues where things I’ve taken for granted are missing – things such as the "VS Command Prompt Here" Windows Explorer context menu items.

Years ago, Scott Hanselman posted INF files to add VS 2005 to the context menu. Using that as inspiration, I’ve created a version of the file for VS 2008 and another for VS 2010. For what it’s worth, I tweaked his VS 2005 file because my copy of VS is installed in "Program Files (x86)" and on older versions of Windows, such as when he posted, it wasn’t.

So enough with the intro; here are the download links:

Right-click to save your file of choice, then right-click on the saved file and choose Install.

Disclaimer-ish stuff: These modify your registry. You should open the files in Notepad first to understand what is happening. Use at your own risk. I’m sure you’re not reading this part anyway.

Good luck.

Meeting Cost Calculator

Main Screen - After RunHave you ever been in one of those meetings where it seems that everyone in the company is there, even though they don’t need to be?  I think everyone has and it is especially frustrating when you are one of the ones that doesn’t really need to be there.

Well, based on a web site I saw a few weeks ago (the link escapes me at the moment), I wrote a little Windows Mobile app that will calculate just how much any given meeting is costing you and your clients.

It’s a pretty simple application.  You press Start, the dollars add up.  You press Stop, and they stop adding up.  You can specify the number of attendees at any given meeting.  You can also specify the default estimated billing rate and estimated cost to your company (for example, estimated average wage + benefits).

You can toggle back and forth between the client cost and the cost to your own company by either clicking on the appropriate region (current is highlighted) or by using the context menu on the Total Cost.  You can also reset the calculator from the context menu of the Total Cost.

Here are a few more screenshots.

Main Screen - After Reset Configuration Screen  Main Screen - Context Menu

You can download this directly to your Windows Mobile phone by going to one of the following links:

I am running WM6 with a touch screen, but it should work on WM5 and later.  I have only tested this on my phone, so your mileage may vary.  Download and run at your own risk.  Feel free to report any issues, comments or suggestions via the contact form below.

Update 1: This program requires the Microsoft .NET Compact Framework version 3.5.

Update 2: I’ve uploaded a new version with the following changes:

  • FIXED: Bug in highlighting currently selected cost
  • FIXED: Bug that always shows total for default number of attendees instead of currently selected number of attendees
  • CHANGED: Continues to run even if device is put into suspended mode
  • CHANGED: Configuration screen allows for higher ($500/hour) and more precise ($5 increments) for cost fields

June? Seriously? (And Tech-Ed)

June is just a week away.  That’s insane.  It’s clichĂ© to say it, but time goes so fast.  My son is already four months old, and my daughter is getting hilariouser by the moment.  (I know some of you may not consider hilariouser a word, but as I mentioned before, I make up words and add them to my dictionary to get rid of the red squiggles.)

So anyway, I went to Tech-Ed a couple weeks ago and it was great.  I had a lot of fun, met a lot of people, caught up with a lot of people I hadn’t seen in a while, and actually learned a few things in the process.  Maybe someday I’ll put all my new-found knowledge to practical use and make something, ummm, practical.

I went with a co-worker, Brennan, and he got the chance to interview a few people.  He’s posted his videos here.

I also took my new video camera, but pretty much the only footage I got was of Jeffrey Palermo doing a head stand on the dance floor to “Whoomp There It Is”.  I will leave you with that:

PS – Notice that I’m recycling post titles?  It must be getting bad.

Jeffrey Palermo at UWM

On Friday, April 17, Jeffrey Palermo will be giving a full-day seminar on ASP.NET MVC at UWM in Milwaukee.  The event isn’t free, but is affordable at $125 – cheap for a day-long training session, especially from someone of Jeffrey’s caliber.

If you’re interested, you can find out more at Jeffrey’s blog.  I’m hoping to be able to go myself, but haven’t got that worked out yet.

P.S. This is not a WI .NET Users Group event, so I don’t have any more details than what you can find on Jeffrey’s blog.

March? Seriously? (And Tech-Ed)

Well, tomorrow begins March 2009.  This year is already one-sixth over and it has been a blur.  As I get older years seem to go faster, but this one even faster than normal.  Maybe it’s the “big project” at work and the “big project”, errr, new baby, at home.  The work project ends in about another month.  The other one will last a little longer.  Whatever it is, the last two months have flown by.

Also, I found out a couple days ago that I am going to Tech-Ed this year in May.  (Before I know it that will be here, too.)  Is anyone else going this year?

Page 1 of 6

Powered by WordPress & Theme by Anders Norén