Posts

Session Control

 I use vscode a lot now because I find it has a better AI integration than Visual Studio . Although the other day I tried to rename an AI chat session and it was obliterated instead of given a new name. This wasn't the first time I had lost an AI chat session and is very distressing, so I thought why aren't these chat sessions backed up along with the source code and Session Control was born. Session Control is a vscode extension that allows you to save your AI sessions in a .chat folder that you can commit along with your code. Session Control

My Wife's Cognitive Challenge

Image
 My wife is a professional dog trainer and behaviorist. Being the tech geek that I am I coded and maintain her website  https://dogsden.ca . She recently developed a training system called  Barbara Lloyd's Canine Cognitive Challenges , a framework that focuses on cognitive skill building for dogs rather than traditional command based training. It uses structured problem solving tasks to reveal how a dog processes information, forms strategies, and adapts to new situations. In other words, it trains the thinking system, not just the response pattern. Key outcomes of this cognitive approach include: • Stronger resilience and confidence in puppies and young dogs • Improved focus and decision making in adult dogs • Greater curiosity, autonomy, and emotional stability The program had great success in real world training, so she wanted to turn it into a scalable online course. I dutifully coded one up as a subsite under her https://dogsden.ca site. Got it all working...

Kanban and the Methodology With No Name

Image
There is a software development methodology that uses a Kanban board, but it isn’t called Kanban because Kanban isn’t a methodology . It’s just a method, a board with columns and stickies to track work, which this guide says can be used with any methodology and is not a methodology in itself. So I call it the Methodology with No Name(MWNN), like Sergio Leone's character the Man with No Name.  The MWNN is simple. You add a column on the Kanban board that is a prioritized list of work that is ready to start work on next. But the trick is that the column has a reverse WIP limit, where you make sure the number of stickies in the column never falls below the reverse WIP limit number. This way work is never stalled waiting for a sticky to be completely defined and ready to begin being worked on.  That's it. You just do the work in the usual Kanban way respecting WIP limits of all the columns. With the MWNN there is no need for sprints and sprint planning where you try to guess how m...

Test Code

Image
 For a long time, when I first started writing tests, I felt so unproductive writing tests. I would try to write the test as fast as possible so I could move on to the "real" code. Then one day when a production deployment failed due to missing a simple test I realized the critical value of tests, and that good tests are in fact "real" code and they do deliver immense value. I began to see tests as "support beams" for the application that prevent it from collapsing. What are good tests? Good tests are ones that fail only when there is something really wrong. Like the logic was altered unintentionally by some change. Good tests don't depend on data that might change. Good tests happen when you have complete control of all the inputs. If your test is failing when nothing is wrong then make it top priority to fix it, or delete it. No test > not working test. These tests will make you no longer trust your test results and they will lose value. You need ...

ToMethodObject Refactoring

Image
I love refactoring code. To refactor code safely you need automated tests. Some code, especially code not written using Test Driven Development(TDD), make it difficult to write tests for the part of the code you are looking to change. Usually what you face are a class that has many dependencies, so in your test setup, you have to create all these dependencies to inject into the constructor even though many or perhaps all of these dependencies don't even have anything to do with the part of the code you are looking to change. Or the method that you want to write a change for is private and the calling public method has a bunch of dependencies which again many will not have anything to do with the part of the code you are looking to change. You are thinking: "If only this code was in a public method it would be so much easier to test". But you may have heard somewhere that changing the code just to make it easier to test is bad.  This is a terrible line of thought that has ...

Visual Studio "You are not authorized to access {username}.visualstudio.com." error

Image
 I have gotten this error once before and ended up having to call Microsoft support and have someone walk me through the steps to fix this. We went through multiple things to fix it and I didn't write them down. Now when I try to sign into Visual Studio I get this error:  I then tried to sign in with my GitHub account and got a bunch of Error Script popups. Did some googling and found the solution to my problem here . Thanks to BigOine I went to Tools -> Options -> Accounts and changed "Add and reauthenticate accounts using:" to "System web browser" and I was able to login with my regular account and the {username}.visualstudio.com error went away.

The program has exited with code 4294967295

 I had gotten a new laptop at work and had gotten everything transferred and working except when I tried to debug a web application in Visual Studio it would immediately stop and in the output window I could see the message "The program has exited with code 4294967295". I searched the internet and most of the solutions involved Docker issues but I wasn't running Docker. I discovered that I could run it in release mode and then attach a debugger to the process. It was clunky but at least I could debug again. A couple of weeks later my laptop got a Windows update and then I couldn't launch a browser when clicking on URLs in e-mails or in Teams. Searching for a solution on the web for that suggested looking at my default browser settings. Turns out my default browser was set to Internet Explorer 🤯. I use Edge and Chrome from links on my Windows Taskbar.  I changed the default browser to Edge and I could launch a browser from URL links again and finally debug a web appli...

Interface Oriented Code Organization(IOCO)

Image
When I started experimenting with TDD  and specifically writing the test first, I had a sudden realization as I began to contemplate where should I place this new test I was about to create.  I realized that the simplest place for the test would be in a folder structure that matched the UI for a web app or the API for a web API, and then quickly realized it would be helpful to have the production code folder structure match as well. I had been working on several large complex code bases, some web apps, and some web APIs, and trying to find the code that needed to change or where to add new code wasn't obvious from the code organization. The code was organized in the layered architecture style with UI layer, Service Layer, Repository Layer, etc. kind of like the structure Microsoft uses in  "Traditional N-Layer architecture applications" . With folders for Controllers, Views, ViewModels, etc. This architecture-oriented code organization(AOCO) is really good at telling you ...

DbEntityValidationException

When calling SaveChanges  on an entity context object you can sometimes get a DbEntityValidationException  error but it doesn't give you a convenient message as to what the error(s) were.  Here is a code snippet to get a convenient message from the DbEntityValidationException  object: Try context.SaveChanges() Catch ex As DbEntityValidationException 'Capture all default Entity Framework Validation errors like required fields, text size checks etc. Dim errorMessage As New StringBuilder For Each validationResult As DbEntityValidationResult In ex.EntityValidationErrors errorMessage.AppendLine( String .Format( "Entity of type [{0}] in state [{1}] has the following validation errors:" , validationResult.Entry.Entity. GetType .Name(), validationResult.Entry.State)) For Each item As DbValidationError In validationResult.Vali...

Page.ClientScript.RegisterStartupScript not working

Had a website with a master page and in the the page_load event I was calling  Page.ClientScript.RegisterStartupScript to run some javascript based on the current state of the application. In the default.aspx page the script worked fine but in this other page the script was not getting called at all.   After much research I have learned that  Page.ClientScript.RegisterStartupScript only works if the page has a form element that has the  runat="server" set.  Once I added a form element with runat="server" to the other page the script finally started getting called the same as it did on the default.aspx page which of course had already had a form element.

ASP.NET 2.0 DropDownList EnableViewState

In ASP.NET 2.0 the  DropDownList   EnableViewState  doesn't work the same as other controls like GridView . Fortunately Anson Goldade created one that does. You can learn how here:  http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.aspnet.webcontrols/2006-02/msg00149.html

Add Charset and ContentType to ASP.NET web page

The WC3 recommends specifying the Charset and ContentType on all of your web pages. A quick and easy way to do this in a ASP.NET web site with a master page is to add this to the masterpage file: <% Response.Charset = "utf-8" %> <% Response.ContentType = "text/html" %>

system.diagnostic trace not creating file in asp.net

Image
If your S ystem .D iagnostic trace is not creating a file in asp.net make sure the the user that the website/webapp is running under has write permissions to the log file folder(default is web root ie where the web.config is). You can find the user that the website/webapp is running under by going into IIS. Go to the application pool that the website/webapp is running under and the Identity column will show the user that needs write permissions to the log file folder.

Where are UnityContainerExtensions

Image
I had wrapped a Unity container in another class and then was using it to call Resolve and only got one option in intellisense like this: But I was wanting the Resolve(Of T) option like this: Then I discovered I was missing "Imports Microsoft.Practices.Unity" at the top of the class.  Once I added that then the UnityContainerExtensions became available.

How to upgrade a web service to ASP.NET 4.0 with out affecting other services

After you have installed .NET 4.0 on the server open a command window and run: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -norestart -s W3SVC/ID/root/ Replace ID in the line above with the Identifier of the Web Service.  The Identifier can be found by starting the IIS snap in and clicking on the "Web Sites" folder and looking in the right pane.  

How to correctly call a web service in .NET

I came across a problem with calling web services that I had never heard about before. I was creating the client with a Using statement like so: Dim xml As XDocument = TestXml Dim actual ( ) As Byte Using proxy As New My WebService .My ServiceClient actual = proxy . GenerateForm ( xml . Root ) End Using Assert . IsNotNull ( actual ) This is apparently a no no, as it can mask the real error.  For me I was getting this error: "System.ServiceModel.ChannelFactory`1[MyLibrary.PNetTServices.PNetTServicesSoap],  cannot be used for communication because it is in the Faulted state." When in reality when I switched to the recommended client call( http://msdn.microsoft.com/en-us/library/aa355056.aspx ): Dim xml As XDocument = MyXml Dim actual ( ) As Byte Dim proxy As My WebService .My ServiceClient = Nothing Try proxy = New My ...

Using WCF with non-microsoft clients

The default wsdl that WCF creates isn't very friendly for human's and other non-microsoft clients to read. To remedy this you can intsall WCFExtras: http://wcfextras.codeplex.com/ To use it, in your endpoint declaration add a " behaviorConfiguration " element with a name something like " WsdlRedirect ". Then add an endpointBehaviors declaration something like this:       < behaviors >        < endpointBehaviors >          < behavior name =" WsdlRedirect " >            < wsdlExtensions location =" https://testwebservices.website.ca/SomeService.svc "                            singleFile =" True " / >          < / behavior >   ...

"An attempt was made to load a program with an incorrect format.” in IIS 7

Was working on an old website dev region that hadn't been used since we upgraded to IIS 7 and a 64-bit web server, and was getting this error: "An attempt was made to load a program with an incorrect format."   After some research I found the answer here: http://stackoverflow.com/questions/41449/i-get-a-an-attempt-was-made-to-load-a-program-with-an-incorrect-format-error-o The solution that worked for me was to enable 32-bit applications in the AppPool.

Apple iPad Facebook crash

My wife likes Apple she has an iPhone and she wanted something like the iPhone except a little bigger so she could manage her business social media content easier. So we got her a first generation iPad. It worked great until she went to share a link in Facebook using Safari and it would crash.  The crash log said it was a memory issue.  I did some research and tried the "disable all the iCloud stuff" and the problem continued.  Then I discovered this is a problem that started in Sep 2012 and it even happens with the newer iPad's so it can't be a memory problem. It is a problem with Safari on Facebook. So I tried a bunch of other browser's like Dolphin, and Opera and still the same problem.   Finally was about to start selling her on an Android tablet when didn't I find a fix.  Almost sort of wished I hadn't found a fix because I like Android. It's what I have for my phone. But here it is: the Atomic Lite browser(or pay for the full blown ve...

Visual Studio 2010 with TFS can't edit source code

Once in a while when I open a project in Visual Studio and get latest version of source from TFS and I go to type in a source code file it will not auto check out and will not let me type anything.  The quickest way I have discovered to fix this is to click on another source code tab(or open another source code file if there is only one tab available) then go back to the original source code and you should be able to start typing.