Lance Larsen - .NET Architect Madison Wisconsin

All posts in .NET

imageI’m excited to start sharing a lot of research I’ve been doing for my upcoming Hololens development talks…

“Augmented Eyes = Azure Cognitive Services + Hololens”

Where to get started?

Note – everything I’m using including Azure and the Cognitive Services is free, no cost – so don’t hesitate to follow along and get everything setup!  My hope is that you’ll do some really cool stuff and “share-it-back” to our community. :)

1) If you don’t have one – you can sign up for a Free Microsoft Azure Account.

2) Once you have that, login to your Azure Portal.

image

Read more


So pleased that I’ve been able to share the experience of a HoloLens with well over 2000+ people just since //BUILD/ this spring – with likely 1000+ actually being able to experience the amazing view for themselves! (especially demoing four of them at once for 16+ hours at That Conference, the official Summer Camp for Geeks!)

So, now what?  We know what the HoloLens can do…  We know how to “bloom” and “click” – we know the amazing tech specs – we know that RoboRaid is one of the best games of all time – what next?  Simple – HoloLens 201 Tour is in the works!

imageBuilding the Age of Experiences: Hololens + IoT

The Information Age has Evolved, Welcome to the Age of Experiences!

We are living through another critical stage in the evolution of technology, we are at the very beginning of looking at our world through augmented eyes.  We –  and those that follow us — will no longer be satisfied with looking at a flat computer screen at our desks, or even on our mobile devices.  We will come to expect and demand to be immersed within our environment with but a single glance through augmented eyes.

Join Lance Larsen as we explore the technologies that are enabling the Age of Experiences, and how we as developers can unite both the Hololens, IoT devices and sensors to usher in the new age!


imageFYI – here’s a trick so we don’t need to specify our local computer’s name in our web.config connectionString – because if you have multiple developers working on the same code – they each have to have different web.config versions with their individual computer names.

Generally we see…

<connectionStrings>
     <add name=”MyContext” connectionString=”Data Source=MYCOMPUTER; Initial Catalog=MyDatabase; Integrated Security=True; MultipleActiveResultSets=True” providerName=”System.Data.SqlClient” />
</connectionStrings>

What we want…

<connectionStrings>
    <add name=”MyContext” connectionString=”Data Source=.; Initial Catalog=MyDatabase; Integrated Security=True; MultipleActiveResultSets=True” providerName=”System.Data.SqlClient” />
</connectionStrings>



How?

1) Open your “Sql Server Configuration Manager” application.
2) Expand your “Sql Server Network Configuration”.
3) Right-click on “TCP/IP”.
4) Scroll down to “TCP Dynamic Ports” (which will be blank by default) and enter “0” which enables it. 
5) Restart your SQL service and you’re DONE!

Thanks Travis Feirtag (@therobotgeek) for this trick!


( Download Code )

Was looking for a simple and elegant way to log some metric for methods (mainly method name, start time, stop time and elapsed time) – I’ve done this in PostSharp in my article “Holy Grail of Application Profiling with AOP” – but client wasn’t using them.

I’ve used reflection with success in the past, but was having some issues with Async methods not giving their real method names, was getting “MoveNext” instead — so sleuthed around for an alternative and found some awesome C# attributes that I’d never seen…

[CallerMemeberName] – gets the method name calling the attribute
[CallerFilePathAttribute] – gets the path to the C# file
[CallerLineNumberAttribute] – gets the line of the method in code

Combining those with the C# Stopwatch Class – and using the Dispose patter that I love because you can easily code the “using” statement around what you’re looking at ( see below ) – came up with the following cool code that – as always – I love to share.

Emphasis on elegant, to call this code – you can easily do the following…

using (StopwatchLog.Track())
{
   // Your code here...
}

It collects the information about executing method and logs metrics when the stopwatch log is disposed.

Read more


Event

Dates

Location

Chicago Code Camp

April 26

Grayslake, IL

Kalamazoo X

April 26

Kalamazoo, MI

Azure Developer Camp

April 30

Chicago, IL

ALM Chicago

May 1

Chicago, IL

Virtual Hackathon

May 1- June 5    

Chicago and online

VSLive

May 5-8

Chicago, IL

Code For Rockford Brigade Kickoff

May 10

Rockford, IL

//PUBLISH Hackathon

May 16-17

Chicago, IL

//PUBLISH Hackathon – Milwaukee     

May 16

Milwaukee, WI

SharePoint Saturday

May 17

Addison, IL

GoTo Conference – Chicago

May 20-23

Chicago, IL

Codestock

July 11-12

Knoxville, TN

Iowa Code Camp

July 19

Des Moines, IA

That Conference

August 11-13

Wisconsin Dells, WI

Madison Ruby

August 21

Madison, Wi

Devlink

August 27-29

Chattanooga, TN

Chippewa Valley Code Camp

Fall

Thanks to David Giard {djgiard@hotmail.com} for compiling these!


imageAt the February 2014 MADdotNET (@maddotnet) meeting – had David Manske (@davidemanske) from Centare out to talk on what’s new in Visual Studio 2013!  Couple absolute gems of knowledge were passed on – one of them was “SideWaffle Templates for Visual Studio” – I had never seen this – so figure some others may not have seen this either!

Specifically liked seeing the AngularJS templates… Check them out!


Always loved JavaScript and client side scripting ( where appropriate <grin> ) – so when we had a new green field project to start, looked to what the best-in-class technologies were – settled on AngularJS (@angularjs). 

It is a client-side MVC (Model-View-Controller) pattern and it rocks for making SPA (Single-Page-Applications) that emphasize responsiveness.  Take a look at either the AngularJS site, or there are a couple great AngularJS videos on Pluralsight – specifically “AngularJS Fundamentals” and “AngularJS for .NET Developers”.

I know that I have a ton to learn about AngularJS – and wanted to share what I’m learning along the way…

Specifically, have a page that has a list of items to be displayed – and want to filter them by a parameter based on what the user clicked.  So in AngularJS we can separate showing the items to be displayed into one controller – the “CollectionController” – and the filters to be applied into another controller – the “FilterController”.  Found many examples / discussion on how to communicate between the controller, but some seemed to be way overkill or confusing – so got the following code crafted – and wanted to share as it turned out pretty slick! :)

To boot, have the live code running on JSFiddle – which again, if you haven’t played with is WAY awesome!

http://jsfiddle.net/lancelarsen/qjkyM/

Read more


large_jquery_logoIn my blog “NuGet – Limiting updates for jQuery and Bootstrap” – we looked at continuing to utilize NuGet to keep us up to date on the latest jQuery 1.x version ( even though 2.x is out ).  Reason being that we needed to stick with 1.x because we are still supporting IE 7/8. :(

So… jQuery 1.x and 2.x have feature parity – but you want to use jQuery 2.x when you can, simply because it’s a smaller download as they were able to take out a lot of IE7/8 “fixes”.  Note, jQuery’s post on conditionally include one or the other based on the version of the browser.

But we also like to use the cool MVC bundling and minification feature – can we have the best of all worlds? Oh ya… :)

Read more


CFNeed to setup a “Created” DateTime field in your SQL table that is auto-computed to add the current date and time that the field is inserted into the database? 

If you’re doing so in SQL – in the “Default Value or Binding” you just need to enter GETDATE() or GETUTCDATE() – insert a record, and you’ll see the date/time value automatically added to that column.  “…that was easy…”

But how to do the same thing when using Entity Framework Code First?

No big deal here either – as long as you add the couple lines of code described here…

Read more


imageimageI love to say “…if it’s not in NuGet, it’s DEAD to me…” – and for the most part that is very true. :)

If you don’t know what NuGet is – you MUST – look at Introducing NuGet: the smart way to bring bits into your projects

However, as I and many developers need to continue to support IE7/8 – we can’t update to the latest versions of jQuery or Bootstrap, as jQuery version 2.+ and Bootstrap version 3.+ no longer support IE7/8…

Also considering jQuery is continuing to update their 1.* version with updates – how do we handle that and continue to use NuGet inside of Visual Studio to show us when there are updates that we DO want to install?

Here’s the solution!

In your “packages.config” file – add the allowedVersions tag to both as follows ( noting that the right parenthesis looks strange, but it is correct – it means ‘less than version X’ )…
 

<package id="jQuery" version="1.10.2" allowedVersions="[1.9.1,2)" targetFramework="net45" />

 

<package id="bootstrap" version="2.3.1" allowedVersions="[2.3.1,3)" targetFramework="net45" />

imageNow when you open up NuGet ( noting that you need to close and reopen VS and the project ) – you see the following!

For this, we were on Bootstrap 2.3.1 – and only saw an upgrade to 3.0 – but now we see we can upgrade to the latest 2.3.2!  And we’re currently at the latest jQuery 1.10.2 – so correctly don’t see an update – but we will when one comes out. :)

I love NuGet… :)