Posts

Showing posts from 2017

C# Dapper Repository

New Direction I had created a framework for a new Microsoft C# MVC web application at work using XML Serialization for the database to POCO conversion and straight ADO for data transmission. We had an architecture review and were asked to try Dapper instead. The word was that other units were using it. We looked around but didn't find anyone using Dapper Micro ORM with a repository pattern, especially for hierarchical data, so last weekend I set out to create one that I'm sharing on my Dropbox: https://www.dropbox.com/s/n5v1o2zdyhyvjyf/DapperDemo.zip?dl=0   This link is to a .zip file. Hopefully have all the goodies you need to view the code and run it.  The Zip Folder Contents In the “Database” folder I have a document with some description about the solution.  I also have 2 scripts to create and populate a simple database with 3 tables.  There is a Main table, a Child table with a many to one relationship to the Main table, and an Auxiliary table wi...

My Blog Hiatus

Image
I can't believe it's been almost 2 months since I posted anything. Where does the time go? It's probably been even longer since I did a photography post... I've been busy at work and have kind of neglected this blog. I've actually been kind of working on a blog sort of thing at work - a Tech Tip that I send out. I'm going to start posting them here too since they apply. Here's the first one:

Finally - I got an ASP.Net Core app to run! (Updated)

Image
Here I go again... I was following along with the Pluralsight course " Building a Web App with ASP.NET Core, MVC 6, EF Core, and Angular " but couldn't get the first demo app to run. I was stuck in Section 2 - Visual Studio! Bummer! I created a new ASP.Net Core app from scratch and tried to run it out of the box and got the error you see at right. I had zero luck finding a solution online. I searched through the code and the only place I found where there was a "type" property that was likely to be null (it's actually a string value in the file) was in the [app].vs\config\applicationhost.config file: <configuration> ... <configProtectedData>         <providers>             <add name="IISWASOnlyRsaProvider" type="" description="Uses RsaCryptoServiceProvider to encrypt and decrypt" keyContainerName="iisWasKey" cspProviderName="" useMachineContainer="true" useOAEP=...

Very quick - starting to look at MS ASP.Net Core, AngularJS

Image
A New Brain Yesterday at work we got a new employee whom I'll call Neesha. Actually, she came onboard a couple of days earlier but I was out due to surgery my wife needed. Neesha was brought on to work on a side project in my unit. I was very pleased to have someone to talk to about more modern software development technologies. She even suggested that the side project might be suitable to use ASP.Net Core and AngularJS . How cool! Not only was she looking at new technologies (well, new compared to what our mainly Classic ASP shop implements or even considers), but she qualified the considerations with statements along the lines of "if the technologies are suitable for the application and it's requirements"! A thinker! Woo hoo! Some Early Thoughts  I told her I wasn't very familiar with Core or Angular - I'd only had some passing exposure to it in the past few months. I told her that I'd spend some time this weekend looking at some Pluralsight...

You Had Me at TDD (Test Driven Development)

Image
Get On Board! As I may have mentioned, I'm an old programmer. When I went to college I learned a bit about testing my own software but it wasn't emphasized. At least not in the classes I took in the early 1980's. Somewhere along the line I started hearing about Test Driven Design but I'll admit, I don't remember when or where. "Uncle" Bob Martin at Software Craftsmanship In my latest spurt of actually studying software development, one of the sources I've been watching quite a bit on YouTube is "Uncle" Bob Martin. For younger software developers, his name may be more familiar than it is/was to me. Here's an example video:  https://www.youtube.com/watch?v=qkblc5WRn-U . There are a good number of Uncle Bob videos where he discusses TDD; he's one of those (or is the one) that developed the idea of TDD. Basically, TDD from Bob's perspective means you write a test and run it. It will fail, naturally. Then you write the cod...

C# 7 and Beyond!

Image
The Future is Now I watched an interesting YouTube yesterday about the Future of Microsoft C#. I have to admit that I've been on a spurt lately (starting this last February) of being interested once again in software development and a lot of my interest is due to C# (the instigator was getting back into Microsoft MVC with C#). I've been writing software to one extent or another since about 1980. Yeah, I'm an old dude - I'll turn 60 this year. I've been developing software as a primary occupation since 1997. 20 years. Before that I had always written software to some level to assist me in my jobs. In the Navy I wrote a small program on my HP-41CV programmable calculator that would solve passive targeting solutions for anti-submarine warfare (TMA if you're familiar with it). Since I was also tasked with being the secret materials officer, I wrote a database tool for tracking the secret materials. And it did not use an off the shelf database - I wrote my own ...

More Info from Microsoft RE: Visual Studio 2017 Upgrade Woes

Microsoft Responds I posted a few weeks ago about my problems that I encountered when upgrading Visual Studio 2017 from version 15.1 to 15.2 (those different ways that you refer to Microsoft applications sure are confusing. I wish they'd just refer to Visual Studio 2017 as Visual Studio 15 and when they have major updates to, say, 15.2, it would not be as cumbersome to discuss). I had posted my issue to the Visual Studio Developer Community  website which seems to be the new Microsoft website for everything Visual Studio (I wonder how long that will last?). I had some response from Microsoft representative Raja, and he pointed me in the direction of how to fix my upgrade woes. But eventually I un-installed every developer tool from Microsoft that I could, ran a bunch of CCleaner  registry cleanups and reboots and eventually got Visual Studio 2017 up and running again. I couldn't see how to close my post at the Visual Studio Developer Community (Microsoft reps have to do...

C# "IsNumeric" Extension Method

IsNumeric Function for a Loooooooong String Value I had a failure on some production code when testing for a Social Security Number. The code was testing string inputs provided by a file upload to ensure that they were positive numeric and exactly 9 digits long (no punctuation was allowed in the input). That seems easy enough but one of the requirements was to try to provide as much error or validation failure information as possible. If the string wasn't exactly 9 digits that failure information should be returned to the user. In addition, if the string value did not evaluate to a numeric value, that failure information should also be returned to the user. The problem was that if the string was not exactly 9 digits, it could be 20 digits. The code had been using an Int32.TryParse which will successfully test a value up to 2147483647. String.IsNumeric() After poking around, I found this solution which I think is pretty cool. I added an IsNumeric() extension method to st...

New to me but solved an issue - Templated Helpers

Image
Building and Modifying Razor Display Helpers  Note: this post uses Microsoft C# only (as most of mine will). I'm using Visual Studio 2017 with C# 7. I have created quite a few Html Helpers and they come in very handy. These are the C# static method kind such as the following which performs some rudimentary formatting of an address: /// <summary> /// Creates HTML for an Address section. /// </summary> /// <param name="htmlHelper" /> /// <param name="address" />The Address object to create the HTML for. /// <param name="refTypes" />An IEnumerable list of reference types  /// (used to parse the name of the address state). /// <returns>Formatted HTML representing the Address object.</returns> public static IHtmlString AddressInfoFor(     this HtmlHelper htmlHelper,     IAddress address,     IEnumerable<IReferencetype> refTypes ) {     var state = UIHelpers.GetStateName( add...

Implementing IDisposable Properly

Image
The Confusion of IDisposable Maybe it's just me but I have a hard time figuring out the best way to implement IDisposable, let alone when to use the interface. I understand the basics, that you use IDisposable to manage releasing managed and unmanaged resources. But why do you need to use it? I have been looking online for information about IDisposable and there is a lot available, both from Microsoft as well as others. I have to say, though, that I spent some time this morning going through what I find to be the best information source I've seen: Pluralsight's  IDisposable Best Practices for C# Developers by Elton Stoneman You do have to have a Pluralsight account in order to watch this course but it was worth it to me. Note: Pluralsight offers a 10 day free trial on their website. You can also get a free 3 month trial to Pluralsight by joining the free Visual Studio Dev Essentials program. The program has a lot of other features as well, such as the GIT...

Happy New VS 2017 Version!

This last weekend I finally got the VS (Visual Studio) 2017 Version 15.2 upgrade working! It only took 16 days and tons of futzing (assuming futzes have mass). I'm not going to divulge the double top secret solutions here because I posted them on the MS VS website at this link: https://developercommunity.visualstudio.com/content/problem/56762/unable-to-upgrade-to-vs-2017-community-152.html?childToView=62345#comment-62345 I've got my issue solved, but I don't know how to indicate that on the forum post. Any help? Anyway, I've been slow to post this success announcement because I've been coding my little heart away. Now I can start posting about the stuff I intended to when I created this blog - my adventures with (mainly) C# MVC! I'll post again soon!

Of (mild) interest to geeks...

I find it interesting that 20% of the readers (or at least, people who've hit one of my posts online) are using a Windows OS and the other 80% aren't. And 0% (yep, zero percent) are using IE to access these pages. My photography blog  has been up a few years (since January 2014) and it's a bit different: 50% Windows and 19% IE. In both cases Chrome is the #1 browser.

I'm just a poor little developer!

Digging Deep One of the last communications I had from Raja at Microsoft on my issue at Visual Studio Developer Community regarding my inability to get VS 2017 v15.2 running was that their InstallCleanup app (read about it here as part of the installation issues) shouldn't have registry issues: "the installCleanup tool does not fail for registry and file removal" I pointed out to Raja that the log file generated from the InstallCleanup.exe tool had multiple entries of this line: Removing File Associations: Deleting Keys...   Failed - Requested registry access is not allowed. I was trying to go a bit deeper on my own tonight (since it's been a few days since I've heard anything more from MS) and ran a Process Monitor that was tracing registry access events where access is denied. The trace captured 175 times that InstallCleanup.exe was denied access to a registry key, such as this: "7:25:46.2909199 PM","InstallCleanup.exe",...

Das Keyboard Prime 13 - Small Review

Image
The Back Story I've been doing some programming at home (or trying to) since this last February of 2017. During that time I'm grown to dislike the keyboard that came with my HP PC. I've had it for quite a  few years but that's not the issue. I just have never liked how flimsy it felt, missing the old, sturdier keyboards I used in the 80's. The old IBM electric typewriter quality action. Sure, the newer "stock" keyboards might be quieter and have less travel and may be great for laptops, but I miss the old school sound and feel. In addition, the HP keyboard has it's INS , DEL , etc., keys in a weird configuration, squeezed in between the QWERTY and the NUM PAD rather than the more typical ANSI layout . I use an ANSI layout keyboard at work and am used to, and prefer the layout of, the  INS ,  DEL , etc., keys in their 2 rows of 3 keys. In with the new Das Keyboard Das Keyboard Prime 13 With just a bit of research online I decided to get ...

Visual Studio 2017 Community Edition - still can't upgrade

Image
Perseverance Slide Rock State Park, Arizona (I wanted a picture of something positive in this blog post!) Besides my Logitech mouse issue I've also still been working on getting Visual Studio 2017 CE (Community Edition) installed at home but I haven't made any progress. The MS representative pointed me to a cleanup tool and it's log file, which I've tried many times amongst my other guess work. In a default installation on a Win7/64 bit OS, the cleanup tool is at:     C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout\InstallCleanup.exe And the log file is at:     %Temp%\dd_cleanup_YYYYMMDDHHMMSS.log The log file had a section with a number of lines (actually, about 50 lines) that pointed me in one direction and gave me hope: Removing File Associations: Deleting Keys...   Failed - Requested registry access is not allowed. When I first installed VS 2017 CE version 15.0, I could not create a solution from a te...

Driver Training - cleaning up unused USB drivers

Image
The following tale pertains to my Microsoft Windows 7 PC. I'm sure it's pretty much the same for a Windows 7 laptop. I don't know if any of this applies to Windows 8 or higher. Out with the old  As part of my adventure in installing the driver for my new Logitech Marathon Mouse M705  that I posted about in my previous post , I was made aware of a potential issue when installing a new USB device. I am not a real PC hardware guy, as you may surmise... I'm going to point to and refer to one of the many websites I came across while trying to figure out my mouse problems, this page from "How To Geek" at: https://www.howtogeek.com/howto/windows-vista/remove-old-drivers-after-upgrading-to-new-hardware/ Remnants Every time you install a new USB device that requires a driver (and what doesn't?), that driver is installed on the USB port you plugged the device into. If you later plug that same device into a different USB port on your same PC (or lapto...

A better mouse trap - issues with a Logitech Wireless Marathon Mouse M705

Image
The Wonderful Logitech Wireless Marathon Mouse M705 I picked up one of these for my work PC in March, 2017. I didn't know how I'd like it because the description talks about the "Hyper-fast scrolling" - a free-wheeling wheel. After it arrived and I installed it, I still wasn't sure how I liked it. You can spin the wheel and it just goes and goes. A co-worker of mine tried it and he instantly liked it. I have a similar looking Logitech mouse at home, but it's older and doesn't have the free-wheeling wheel. It has a "ratcheting" wheel like most mice. I found that, after a week or two of having the M705 at work, I was trying to use the hyper-fast scrolling at home and had got to where I decided I needed another M705 at home. I really like the way it handles! A new mouse in my house I ordered a second copy from Amazon  for about $20. Note that the Amazon price fluctuates. As I'm writing this, the price on Amazon is $27.42. Also note ...

Quickly getting nowhere - VS 2017 v 15.2 Update failure

Image
Can't update VS 2017 Community to version 15.2 I've gotten nowhere with installing this update. I've been looking at tons of stuff on the web (okay, I'm really not sure how much a webpage weighs) and trying it but to no avail. I have had VS 2017 installed since a day or two after it was released (I didn't have any of the release candidate versions installed). When I started this update I lost my internet connection in the middle of the process and haven't been able to recover yet. Unsuccessful Steps In the last couple of hours today, here's what I've tried with no luck: Uninstall GIT ( https://developercommunity.visualstudio.com/content/problem/2812/install-of-git-holds-up-install-but-list-of-progra.html ) Uninstall Microsoft visual Studio through Control Panel > Programs and Features. Uninstall Failed. Deleted contents of these folders  C:\Program Files (x86)\Microsoft Visual Studio\*.*  (https://developercommunity.visualstudio....

Premature Installation

I'm off to a great start. Just like swimming with sharks. I have recently started some studies on Microsoft MVC 5 at home. I first installed the Visual Studio 2015 Community Edition but when VS 2017 CE was released on March 31, 2017, I installed it. I've been using it almost daily since. Note: I am using VS 2017 Professional at work. On May 10, 2017 Microsoft released the version 15.2 (26430.04) update. Last night I decided to install it - I was hoping for a quick install. Instead, I lost my internet connection and the update failed. I spent the rest of the night trying to repair the damage and still haven't fixed it. After resetting my modem and router I tried the installer again but it didn't work. The install log says the RPC call failed. I don't know why it works for part of the installation process and then fails. I found a lot of suggestions online and have tried a lot of them so far, including deleting the installation folders. After each step I...

Greetings!

Image
Initialization Yep, another software developer blog. What makes my blog different is the URL. About Me I have been programming to one extent or another since about 1980 when I started using BASIC on a TRS-80 Model 1. Yep, as of now, that's about 259 dog years. And it feels like it at times. I started my education in programming in 1983 as part of my electronics engineering degree program. I started working full time as a software engineer in 1997 but I did some amount of programming at every job I had between 1981 and 1997. This included charting and statistical software for hardware that interfaced to the PC, an inventory system, an RV parts sales and repair catalog, an inventory database (from scratch - not using any off the shelf database application) for tracking secret materials for the U.S. Navy, a submarine location, course, and speed estimation program, employee scheduling system for the State of Oregon, and more little projects. In 1997 I created a WANG wo...