Fix: Office Updates and Malwarebytes

If any of you are big fans of Malwarebytes (and why wouldn’t you be?) you may be experiencing crashes in Office 2013 and 2016 under Windows 10.

Microsoft has identified the problem: https://support.office.com/en-us/article/Fixes-or-workarounds-for-recent-issues-in-Word-for-Windows-bf6bf17c-2807-4871-83ce-e337ae8f0b86?ui=en-US&rs=en-US&ad=US

The workaround is to use the latest beta of Malware Bytes: https://forums.malwarebytes.com/topic/200230-malwarebytes-version-310-beta-available-for-download/

Hope this helps!

Enabling HDR for XBox One with Samsung 4K TV

(Skip to the bottom for the instructions after my tale of woe)

Yesterday I setup a new 4K Samsung UN65KU650D TV with HDR.

Of course the 1st thing I did was to hook it up to XBox One to see it in all its 4K HDR glory! Once I selected the correct HDMI input, XBox One automatically recommended switching to 4K (very cool!). I also wanted to make sure it was also displaying in HDR.

I went to Settings > All settings > Display & sound, then chose Advanced video settings > 4K TV details as described here (https://support.xbox.com/en-US/xbox-one/console/checking-your-tv-4k-hdr-capabilities-on-xbox-one-s).

While 4K HDR was detected, HDR could could be found at any refresh rate and was therefore disabled for Video and Games. (Lots of yellows and reds, not nearly enough green checkboxes)

As you can imagine, my heart sank! But fear not, this is just some silliness on Samsung’s part, I imagine for compatibility with devices that don’t support HDR.

By default, this Samsung TV has HDR disabled for all inputs. To enable it for your XBox One (or other HDR device):

1) Turn on the TV and turn off whatever device will be using HDR.

2) Hit the Home button on your remote to bring up the menu
4khdr13) Choose the Settings icon (looks like a gear or cog)4) Choose Picture
4khdr35) Choose Expert Settings
4khdr46) Choose HDMI UHD Color
4khdr57) Choose the HDMI input you are using for your XBox One or other HDR capable device and select “On”.
Click “Close”
4khdr6 8) Turn your XBox One (or whatever) back on.
Go to Settings > All settings > Display & sound, then choose Advanced video settings > 4K TV details
It should now look like:
4khdr7
9) (Optional but highly recommended) Play Mass Effect: Andromeda in all its HDR glory!

Create 1 Frame Animations in Unity 3D

I was looking to make a 1 frame animation in Unity and wasn’t able to find a guide. In case anyone is curious, this is what I did:

When making a multi-frame animation, you can simply select all of the frames in a sprite and drag them to the prefab. This creates the animation for you. However, if you drag just one frame from the sprite, it will add it as a sprite renderer.

If you would like  a 1 frame animation from that sprite, right click the frame you want in the Unity Editor and click Create->Animation

Ta da! You’ve now got a 1 frame animation.

Installing Network Policy Server from PowerShell

Recently I encountered a strange error where I couldn’t install Network Policy Server from the Server Manager.

Rather than fight with Server Manager, I punted and installed it via PowerShell. The installation that way worked without an problem.

Run PowerShell as Administrator

Run:

Import-Module Servermanager

Run:

install-windowsfeature -name npas-policy-server -IncludeManagementTools

That’s it!

Fix: Unable to Auto-Update WordPress 7.1-7.2

When attempting to upgrade WordPress 7.1 to 7.2 I received the following error:

The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.: wp-admin/includes/update-core.php

A little Binging around and I found the solution here:
https://aaronjholbrook.com/wordpress-permissions-update-error-resolved/

Just in case that site goes down, here’s what to do:

SSH into your web server and run the following 3 commands:

Reset the permissions of all files to 664:

find /path/to/site/ -type f -exec chmod 664 {} \;

Reset permissions of directories to 775:

find /path/to/site/ -type d -exec chmod 775 {} \;

Reset the group to the apache group

chgrp -R apache /path/to/site/

Fix: Windows Media Center Can’t Update

If you’re still using Window Media Center to power your OTA cable cutting hotness: go you! We are a dwindling number :p

I recently had a problem where I kept being alerted that the guide data only had 3 days left. Allowing it to download the data did not seem to fix it.

(As a side note: it was also showing the wrong program icons for TV shows.)

The fix it turns out is very simple (so you can hold off buying that Tivo Roamio OTA for now):

Start->Run
C:\ProgramData\Microsoft\eHome\mcepg2-0

Delete all of the files in that folder. There will likely be 3 files and folder:
Root.mem
Events.mem
Blocks.mem
backup

You will probably be told that you can’t delete one or more of the files because they are in use by some process.
Don’t cancel, leave that message up and continue following these instructions.

Press: Control-Alt-Delete
Choose Task Manager
Click the “Processes” tab
At the bottom, click the “Show processes from all users” button.
Click the column header that says “Image Name” to sort by name (and make your life easier).
Find the process that in the error message when you delete.
Click the process, then click the “End Process” button in the lower-right corner.

In the error message window that said you couldn’t delete, click “Try Again.”
Repeat this process until all of the files are deleted.

Launch Windows Media Center
Go to Guide
You should now see a full schedule of programs.

Restart your Windows Media Center computer to make sure all of the processes you ended are started back up correctly.

Where’d the Timer Go?

So. System.Threading.Timer. Right.

I’m really starting to miss the old System.Timers.Timer. Built like a tank. System.Threading.Timer is a bit more finicky, but is the only option in .Net Core.

My fun of the day:

It turns out, when the timer goes out of scope, it will be disposed of. Even if you’d told it to, for example, tick every 3 seconds. Though I probably should have known that.

This will tick exactly once:

private void foo()
{
Timer t = new Timer(bar, null, 0, 3000);
}

Instead, you must do:

Timer t = null;
private void foo()
{
t = new Timer(bar, null, 0, 3000);
}

Just so you don’t waste a couple of frustrating hours like I did.

Happy coding!

Getting to the (.Net) Core of It

Migrating a .Net 4.x Console Application to .Net Core

I finally got the server side of Winds of Paradise running in .Net Core! I thought I’d share how it did in, in hopes that it might help you do the same. As cool as Mono is, I’m totally psyched to have all my C# code running on Microsoft’s .Net under Centos Linux!

If you haven’t watched it yet, I highly recommend Microsoft’s .Net Core lesson at the Microsoft Virtual Academy:
https://mva.microsoft.com/en-US/training-courses/introduction-to-net-core-16764?l=DoVafl7yC_7606218965

1st thing I did was update Visual Studio 2015 Community to Update 3 and install all of the prerequisites. These can be found at: http://getdotnet.azurewebsites.net/target-dotnet-platforms.html

You can also find instructions there on how to install .Net Core onto wherever your code will be hosted.

Once everything is installed (block out a good hour for this), I opened my existing solution in Visual Studio.

To the solution, I then added another project and chose the type: Console Application (.Net Core)

dot-net-core-console

Next, open that project and use the NuGet Manager to install any packages that you are using in your .Net 4.x project. For me, this was npgsql and Newtonsoft.JSON.

Once the new project is created, copy over all of your .cs files from your original project to the new .Net Core version.

Hit build, and start working on replacing any .Net 4.x functionality that is not available in .Net Core.

What I did was make corrections in the .Net Core version and then replicate those changes in the .Net 4.5 version. This way, I could build and run the old version with minor changes to prove the changes worked, rather than changing *everything* and trying to debug the .Net Core version. This worked, since the .Net 4.x encompasses everything .Net Core does.

Once you’ve worked out all of the bugs, copy all of your code over to whatever box your running on .Net Core on (Windows, Linux, MacOS, etc.).
Open a shell, cd in the folder with project.json and run:

dotnet restore
dotnet run

That’s it! .Net will download necessary packages from nuget, compile, and run.

Here’s some of the classes I had to find workarounds for:

System.Net.HttpWebRequest, System.IO.Stream.GetReqestStream:
The .Net Core version of this object only has async methods for GetRequestStream and GetResponse. You’ll have to move to GetRequestStreamAsync and GetResponseAsync, which also means having your methods return Task instead of void
Also, the .Net Core version does not have HttpWebRequest.ContentLength when doing a POST. So far, simply removing it seems to work fine in both  .Net 4.5 and .Net Core.

NpgsqlDataAdapter:
I’m guessing this could probably be made to work with .Net Core fairly easily, but moving NpgsqlDataAdpater usage to NpgsqlDataReader for better database efficiency has been on my TODO list for quite a while anyway.

System.Configuration:
I found a great resource for setting up json configuration files at:
https://csharp.christiannagel.com/2016/08/02/netcoreconfiguration/
A couple notes:
1) I had previously been targeting .Net 4.5. I needed to target 4.5.1 in order to install Microsoft.Extensions.Configuration
2) If you create appsetttings.json in your .Net 4.5 project 1st, make sure to create appsettings.json in your new .Net Core project, DON’T COPY it from from the .Net 4.5.1 one. Creating it new sets it as a “Content File”

System.Timers.Timer:
This was a tricky one. System.Timers.Timer allows easily add/subtracting events from occurring on the timer with Elapsed += [function].  This allowed me to have a couple of static timers that any other object could add events to.
The only alternative in .Net Core is the System.Threading.Timer. This timer is much less sophisticated. It can only accept one function to run at each tick, and this function cannot be changed. My workaround was to implement a separate timer for each object that needed one. I’m hoping this does not increase resource consumption. Hopefully a better timer alternative will work its way int nuget, I didn’t see anything that looked promising at the moment.

Happy coding!

Lync 2011 Mac Keychain Error

Today Lync 2011 decided it was not going to log in. Each time I tried I got an error about the oc_keycontainer and a request for my password.

I tried just deleting all the oc_keycontainer entries from Keychain Access, but still no luck.

It turns out it’s necessary to also delete the OC_KeyContainer_[username] file from ~/Library/Keychains

Re-launch Lync, and all should be good.

Fixing OpenVPN in pfSense After Static IP Change

I recently moved (yay me) and with the move came a new static IP address.

Unfortunately, changing the IP address in pfSense did not change it in the OpenVPN configuration as well.

If this happens to you, here’s the fix:

Log into pfSense, go to Status->Services and stop the OpenVPN service.

Next, SSH into the pfSense router with something like:

ssh root@[your router]

Once you are in, press 8 to get a shell

Enter the following command:

vi /var/etc/openvpn/server1.conf

Go to the line that starts with “local” followed by your external IP address

Change your current IP address to your new external address, then save and exit vi.

Go back to the pfSense web interface, go to Status->Services and start the OpenVPN service.

You should now be able to connect! (You’ll need to change your client configs as well if they are pointed to your IP rather than a DNS address)