Attach to Process

Thoughts and Notes on Software Development

For some reason, maybe because I accidentally pressed something on my keyboard, Visual Studio 2019 started comparing code in inline mode. By inline mode, I mean I only got one code comparison window, and the changes were stacked on top of each other. This made it hard for me since I was so used to the side by side code comparison mode, where I had two windows and I can clearly see what's different between files.

It took awhile for me to figure out how to set it back. I spent some time looking through the options in Visual Studio but couldn't figure it out. I even had a hard time searching the internet for answers, because I wasn't sure what to search for. The search key that finally worked for me was “vs 2019 diff inline mode”. That led me to the Stack Overflow post I linked below.

Side-note: I find it hilarious that the question in Stack Overflow was for Visual Studio 2012. Here I am with Visual Studio 2019 and the answer still works. Amazing. And what a gem Stack Overflow is for software developers.

Anyway, there are two ways to set it back to side-by-side mode. You can use the shortcut button for it in the menu bar. Or, you can use the shortcut CTRL + \, CTRL + 2.

Visual Studio Diff View Modes Shortcut

Reference:

How to switch view modes in built-in Diff viewer of Visual Studio 2012 and 2013?

Tags: #VisualStudio

Discuss... or leave a comment below.

When you just want to do a simple WCF service test, you don't need to download third party tools. You can use the WCF Test Client app that usually comes as part of a Visual Studio installation. I keep forgetting where to find it, so I'm writing it down on here to remind myself.

I had Visual Studio 2017 installed on my PC. Here is where I found the WCF Test Client app (WcfTestClient.exe):

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE

Tags: #WCF #DotNet #VisualStudio

Discuss... or leave a comment below.

A week ago I was running a test and kept running into a WCF BindingConfiguration Error. I would not allow myself to check-in my code unless my tests passed. So, I battled with this error for over an hour.

The binding at system.serviceModel/bindings/basicHttpBinding does not have a configured binding named ‘BasicHttpBinding_IXXXXXX’. This is an invalid value for bindingConfiguration.

It's your basic, run of the mill, WCF BasicHttpBinding configuration error.

I double-checked my test project's app.config file and the relevant client.config files – everything looked right. I know it was a configuration issue. The error message itself made it obvious that it was a configuration issue. But everything looked right. I didn't see any issues with the config files I was looking at.

It must be noted that it was already close to midnight at this point. I was working late that day and decided to push myself by resolving to check-in my changes before the night ends. I have no doubt that being tired and sleepy didn't help.

Anyway, after awhile I realized that the service method that I was trying to test, was running inside another service. So, in addition to the test project’s app.config file, I also needed to double-check that other service’s Web.config file. When I ran into this error earlier that night, I actually updated that other Web.config file. I added the entry it needed just to cover my bases. I didn't know then that it was the Web.config file that was causing the error.

For some reason, possibly due to fatigue and needing sleep, I didn't think about checking that Web.config file again. Out of frustration, I decided to take a break and headed to the kitchen to drink a glass of water. After hanging out in the kitchen for a bit, then listening to some good music, I finally had the bright idea to check this other Web.config file again. And there it was, a typo on the BasicHttpBinding entry I added. Can't believe I didn't check on it sooner.

Lesson learned here is to take a break whenever you're stuck with a problem. Give your mind time to rest. Chances are, your subconscious will kick in and tell you what to try next. And if the problem points to a configuration issue, with WCF, it most likely is. So, check all the config files, again.

Tags: #WCF #CSharp #DotNet

Discuss... or leave a comment below.

This seems like a great primer for learning how to use CSS to improve readability of posts on your site. It covers a bunch of CSS topics like font size units, letter and word spacing, width and alignment of text, etc...

Link: Modern CSS Techniques To Improve Legibility


This post is Day 36 of my #100DaysToOffload challenge. Visit https://100daystooffload.com to get more info, or to get involved.

Tags: #Bookmarks #WebDevelopment #100DaysToOffload

Discuss... or leave a comment below.

Was running into a build error in Visual Studio 2017. The Output window says 1 project failed, but the Error List window was empty. The only way I managed to figure out what project was failing, was to copy the contents of the Output window, paste it into Notepad++ and search for the word “FAILED”.

Anyway, I finally figured out that it was the SQL database project that was failing to build. And it turns out, it was getting an “Out of Memory Exception”. Not sure if this specific error causes the Error List window to come up empty. In any case, at least now I have an idea of what to look for whenever this happens again.

Tags: #VisualStudio

Discuss... or leave a comment below.

Bookmarking this before I forget... again. This is a pretty cool, easy to use, open source virtual whiteboarding tool. It allows you to quickly create workflow diagrams using just a browser.

Excalidraw is a whiteboard tool that lets you easily sketch diagrams with a hand-drawn feel.

Link: Excalidraw | Source Code

I would have never discovered Excalidraw had it not been for this post by Erik.

Tags: #Bookmarks #Tools

Discuss... or leave a comment below.

Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won't work anymore. However, the idea and logic described in this post, is still applicable for posts that you wanted to add a Previous or Next link to.

In Part 1, I covered how I generated links to the Previous and Next post for my “indexed” journal entries. In this post, I'll talk about how I generated the links for non-indexed journal entries.

Handling Old Journal Entries

So, now that I have navigation working for my “indexed” entries. I turned my attention to my precursor journal entries. These entries don't use base 10 numbers as indexes in their slugs/URLs. For example, the post slug for Journal Entry – I ends in “I”, which is a roman numeral. Same goes for Journal Entry – II, III, IV and so on. To further complicate things, I decided to leave the post slugs unchanged for other precursor journal entries. The post slug for Journal Entry – XV for instance is still “decisions-decisions”. I thought about writing JavaScript that would convert roman numerals to base 10 numbers. But then that won't work for non-indexed entries like Journal Entry – XV.

Shot myself in the foot right there, huh? >_<

Read more...

Update 06/22/2020: Didn't realize that the JavaScript that I talked about in this post, was actually creating a Next link for this post. It thought this was a Journal Entry post, because it found that text in here. That's hilarious, but that is also part of the fun of tinkering. I have fixed it.

Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won't work anymore. However, the idea and logic described in this post, is still applicable for posts that uses index numbers for post slugs. For a working example of this, check out the posts on my photo-blog.

Finally got full blog post navigation working for my Journal Entries. If you have JavaScript enabled on your browser, you could effectively navigate from Journal Entry – I up to Journal Entry – XVI, then continue on to Journal Entry – 001, all the way up to the latest one (as of this writing), Journal Entry – 060. You can also navigate from Journal Entry – 060, all the way back down to Journal Entry – I.

Getting Post Slug and Index

To make navigation work between blog posts in a series, I made use of a standard format for post slugs/URLs. I call them “indexed” entries because I added an index to the end of the slug/URL. For example, “journal-entry-001”, “journal-entry-002”, “journal-entry-003” and so on. It's really just a way to help me figure out the sequence of posts.

So, first off, here is the JavaScript for getting the post slug from the URL. Then from there, getting the post index from the slug. Without this code, it will be impossible to automatically generate the links to the Previous and Next posts.

var element = document.querySelector('meta[property="og:url"]');
var content = element && element.getAttribute("content");

// Get post slug
var postSlug = content.split('/').pop();
var postIndex = postSlug.split('-').pop();
Read more...

Was playing around with Blazor and created this site. It is a static site that has web apps written in C# instead of Javascript. Why? Because with Blazor, you can.

Next step is figuring out how I can embed Blazor apps.

Tags: #AspDotNet #Blazor #DotNetCore

Discuss... or leave a comment below.

Unintentionally running data manipulation scripts on a Production database is obviously bad. In this post, I'll share some tips for working with Production databases so the same thing doesn't happen to you.

1. Check your Database Connections

Double-check your database connection before running any scripts. Oftentimes, this simple check is all you need to do, to avoid accidentally deleting data in a Production database.

2. Start new instance of SQL Server Management Studio

When connecting to a Production database, start up a new instance of SQL Server Management Studio. The idea is to keep scripts between Production and other databases separate. This helps you distinguish between database connections. And hopefully stop you from running a script that will mess up the Production database.

3. Work off Database Backups

Better yet, if you have the option, restore a backup copy of the Production database on a dev box and work off that. This way, you can mess with the data and not worry about affecting Production.

Note: Make sure restoring database to a local dev box is allowed per your company policy.

4. Use Database Transactions

If the script you are running has the potential to change a databases' data or schema – like if it has the words ALTER, CREATE, DELETE, INSERT, UPDATE, or any other statement that can modify the contents of a database – then you should be wrapping the scripts in a transaction. BEGIN TRAN is your friend. I do this even when I'm running the scripts on a local database instance. It might sound like overkill to use transactions on scripts running on non-PROD databases, and maybe it is. But what's an extra 10 seconds or so of doing that, if it prevents you from accidentally blowing up the Production database? I do it for peace of mind. It's part of routine for me now. Anytime I write a script that has the words ALTER, CREATE, DELETE, INSERT or UPDATE, I wrap them in a transaction. Doesn't even matter what database I'm connected to.

This is how I wrap scripts in a transaction:

BEGIN TRAN

-- ALTER, CREATE, DELETE, INSERT, UPDATE Statements go here

ROLLBACK TRAN
COMMIT TRAN

I use it this way: I highlight the scripts starting from BEGIN TRAN and stop just before the ROLLBACK TRAN statement. I run those and double-check the results. This gives me the opportunity to either ROLLBACK or COMMIT depending on the results.

Also, you'll notice above that I have a ROLLBACK TRAN just before the COMMIT TRAN statement. This is just an extra safety precaution that can be especially useful when you're sending out scripts to someone else. They might accidentally run the scripts in a Production database, but the ROLLBACK TRAN will make sure nothing bad happens.

5. Close Instances of SQL Server Management Studio

Before going home or logging off from work, close any instances of SQL Server Management Studio, especially those that you used to connect to a Production database. You'll want to do this because closing an SSMS instance while you have an open transaction, will cause it to display a warning. An open transaction has the potential to block queries and cause timeouts. This will remind you to either rollback or commit your transactions before logging off.

That's it for today. I hope those tips are helpful. If you have your own tips for working with Production databases, do share them by leaving a comment below or sending me a message.

Tags: #Database #Scripts #SqlServer

Discuss... or leave a comment below.

Enter your email to subscribe to updates.