Posts

Dude, Where's My Framework?

Image
You start out your day with a nice cup of coffee, and think, "Ah, greenfield project day...smooth sailing".  You fire up Visual Studio and create a new C# project.  "First things first, I need library X." you say.  "Wait, what the?"   The full error:  Package 'MyPackage 1.0.0.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.   "Ok" you think, "That library is a bit older.  I'll go update the library project to .NET 6 to match my project.  But, where is .NET 6?     "Ok, what about my new project?  Just as a test, does the warning go away if I set it to an older .NET Framework?  Wait, where are the .NET Framework versions?"

Permanently Mapping a Windows Share on Linux

Every few years, I have to set up a fresh Linux box, and I typically want to connect them to some Windows file shares.  There are many resources on how to do this, but many describe approaches which are incomplete, insecure, or not permanent (across reboots).  Here is what has worked for me. Note: The approach I describe comes from https://wiki.ubuntu.com/MountWindowsSharesPermanently.  I repeat it here because it gets buried in the search results (and I add a few details they gloss over & tweak a few things).  It is worth reading that as well.   Run these commands in order from the console.   Note: The two "nano" commands open a file editor. I have included the necessary file contents below. After updating/creating each of the files, save & exit the editor, and continue with these commands. You should now be able to browse to the local folders you entered in fstab and view the shares.

Initialize With Care

Pointers are funny things.  They are one of the make or break concepts for beginners, and even years later, they can cause grief to experienced developers.  I am no exception.  Here is one such story: I was faced with a class which I wanted to refactor.  It can be simplified as follows: In the interest of breaking up the responsibilities, I added a couple of interfaces. The idea is that I can pass around smart pointers to these interfaces and begin to decouple portions of the code.  For example, I can inject them into classes that need them: However, I made a mistake.  I blame it on years of using boost::intrustive_ptr instead of std::shared_ptr, but enough excuses.  Let's see if you can spot it. Do you see it?  If so, give yourself 5 points.  If not, maybe after seeing the output: 'second' going out of scope... Destructor 'first' going out of scope... 'root' going out of scope... All done... Both shared pointers ( first & second ) are created from the

Making a Windows Dark Mode Toggle Button

Image
There are many posts around the interwebs showing how to toggle Windows dark mode based on time of day.  I had a slightly different need.  I often work outdoors, so going back to light mode on demand is handy.  After a bit of digging, I came up with the following:   Save that script in a file with a .ps1 extension, and it becomes an executable Powershell file which will turn dark mode on/off when run.   Personally, I wanted a button on my start menu to trigger the script, so the rest of this post is just a description of how to trigger an executable from a start menu icon. First, create a shortcut by right clicking file and selecting "create shortcut".  You can choose a nice icon to go with it if you like.  The command should be something like this: powershell.exe -ExecutionPolicy Bypass -File "ToggleDarkMode.ps1" Note: Read up on powershell execution policy to determine the appropriate setting for your situation. Then, save the shortcut in C:\ProgramData\Microsof