Sunday, February 28, 2021













 

Tuesday, November 29, 2016

Qt5Package Extension and Win32/x64 Configurations in VS 2015

I may be using this awesome Visual Studio 2015 extension incorrectly; however, whenever I import a Qt Creator PRO file into Visual Studio using it, I get the default Qt configuration which is my x64 config.

When I go to add a Win32 Configuration, I get errors about how "There's no Qt version assigned" and it instructs me to change the Qt version.  The problem with that, is that when I try to do this via the Qt properties on the project the extension tells me "Value cannot be null. Parameter name: qtVersion."

I beat my head against the wall a bit trying to fix this and none of the online suggestions solved my problems until I found a 'several pages in' post saying to do the following:

Open your newly created project's .vcxproj file in a text editor, scroll down (usually near the very bottom) until you find some user properties for the extension.

In my project they were found in the section (this screenshot shows the location as well as the fix):


(Click on image to expand)

In my project file, before I edited the UserProperties element, there was no name/value pair for Qt5Version_x0020_Win32 - the entry only had the value for x64.

Knowing that I had configured the extension with a Win32 version with the name "Qt 5.6 x86" I added the missing name/value pair, saved the project file, re-opened it in Visual Studio and was successfully able to build.

The string YOU use for the value of Qt5Version_x0020_Win32  or Qt5Version_x0020_x64 will be dependent upon how you have configured your extension.  For example, if you have not yet defined a Qt version that points to an x86/Win32 version of Qt - you won't be able to reference it from the project file.

You may have the reverse of my problem in that your default Qt installation referenced by the extension is the x86/Win32 version of Qt.  In that case, you'll be missing the other value (which I already had.)  Just use the same process and you should be fine.

Hope this helps!

Tuesday, December 1, 2015

Building Qt 5.5 minibrowser sample application

For the life of me I couldn't understand how a basic sample application in Qt could fail to run, everything else was great - just not the minibrowser sample.

I was getting the error -

Starting C:\Qt\Examples\QtWebView\1.1\webview\build-minibrowser-Desktop_Qt_5_5_1_MSVC2010_32bit-Release\release\minibrowser.exe...
QQmlApplicationEngine failed to load component

qrc:/main.qml:44 module "QtWebView" is not installed

- when running the built sample.

After much grumbling and searching (I didn't find anything helpful on the inter-tubes which was really surprising) - I found that the main.qml file was referencing the following:

import QtWebView 1.0

I found that if I changed this to:

import QtWebKit 3.0

It would run properly (I presume.)

This may be sidestepping the actual issue, but this appears to have fixed this sample for me.

This version was the one I found in the plugins.qmltypes in the qml import path.  Perhaps I had not configured an import path properly when installing Qt - it's possible this is entirely my fault; however, if it is not, hopefully this will help someone.

Tuesday, October 7, 2014

Repairing .NET 4.0 in Visual Studio 2010

I recently had problems installing security patches to the .NET 4.0 runtime, you know, the kind of problems that give you an absolutely generic installer error that leads absolutely nowhere.

Anyhow, I tried uninstalling .NET 4.5 and 4.0 completely and re-installing them - great, all fixed except for one problem - Visual Studio 2010 could no longer target .NET 4.0 (much less .NET 4.5+.)

Repairing Visual Studio didn't fix it, a whole slew of inane ideas and attempts didn't fix it - ultimately I found a guy who had a way that DID work for me that was short of uninstalling and installing Visual Studio again.

Just install the "Windows Phone Developer Tools" from 2010 (Web Installer.)  Running it will download all of the components and then it will begin installing, the second thing it installs is the .NET 4.0 multi-targeting pack.  As soon as that second item finishes installing just cancel the install - it won't roll you back.

Presto!  Visual Studio now recognizes .NET 4.0.

Thank you Xander Hyde wherever you are! -> http://tinyurl.com/qhtok24

Friday, May 23, 2014

Mono / Unity3D C# HTTPS HttpWebRequest Asynchronous craziness

Beware, ye crabby developers, of using HttpWebRequest asynchronously with SSL connection because there appears to be some crazy bug that causes a timeout (defaults to 100 seconds if I recall correctly) that yields a null response.

I spent the entire morning (and I ran into this previously on iOS a year ago and put it aside for a day when I felt like bashing my head against rocks) wondering why some simple asynchronous download management code I'd written work wonderfully for FTP and HTTP but then nothing seemed to happen when using a URL with HTTPS as the protocol...

I did the usual things like ASSumed it was a self-signed cert issue so I overwrote the certificate acceptance code - no luck.  I spent a bunch of time trying to understand the error messages I was catching on exception, ultimately tracing it down to a timeout on the OTHER end of the connection yielding a "connection forcibly closed" which told me that my server was actually saying "look meathead, if you're just going to sit on the line I'm going to cut you off so I can help someone else..."

So, I started Googling.  An hour later after reading about a ton of other people having this issue (but nothing mentioning 'debug') I caught a little bugzilla entry mentioning 'odd behavior' with HttpWebRequest when running in DEBUG.  So, having exhausted all rational attempts to resolve the issue I said "screw it, let's see if it works in release, guffaw, chortle..."

Bang, 8 simultaneous HTTPS downloads worked like a charm.

Un-FREAKING-believable.

So, if you too have crazy HTTPS issues that defy reason and you're using Mono/Xamarin/Unity3D, give your friendly neighborhood release mode build a try and see if it magically solves your ills.  I know mine did.

Hey Mav, do you still have the number of that truck driving school?  Truck Masters I think it was called...

Tuesday, April 29, 2014

WordPress Multiple Install IIS URL Rewriting Problems

Okay...  This has given me a gigantic headache (both figuratively and literally) all morning and thank goodness I've finally managed to hack a solution to it...  Technically it isn't a hack, but it sure smells like one.

We have an unusual situation where sales & marketing has its own WordPress installation at the root of our website and the support group has its own separate installation under /support.

The web server that we're currently using is an IIS 7 server, which means that WordPress is operating with no .htaccess files and using web.config.  Each base directory has a web.config.  Each WordPress is using its own Database and has its own database user.

So...  Problems arose when enabling permalinks (pretty ones) for the support site.  I couldn't figure out why going to any of the site pages was yielding a 404 error (emitted by WordPress' PHP.)

My hosting provider couldn't figure it out either - which really got me worried, so after slogging around endlessly, and reading about all the other people using multiple installs and having minor configuration issues, I really started to pull my hair out lol...  I then ran across an obscure post about a guy mentioning WordPress and ASP.NET configuration inheritance issues.  This led me to other posts about nested ASP.NET applications issues, which ultimately led me to the following magic:

<location path="." inheritInChildApplications="false">

Thanks to the wonderful person found at:

http://articles.runtings.co.uk/2010/04/solved-breaking-parent-webconfig.html

Basically, IF you have a WordPress installation in a sub-directory of your website that is hieararchically a child of another WordPress installation, and you're on an IIS web server, you need to edit the root WordPress installation's web.config file and surround it with the location element.

After doing that, my permalinks started working again just fine.  (Thank G-d...)

Tuesday, April 8, 2014

Visual Studio 2010 Web Publish over FTP

It seems like you can't use TLS or SSL to protect your FTP data when publishing from Visual Studio, but I just found out that you can.

There's no direct "FTPS" publishing mode, you simply select "FTP" and then make sure you use the correct protocol in the URL (i.e. "ftps://ftp.mysite.com/somefolder")

Many people probably knew that but I didn't...

Tuesday, April 1, 2014

Wide Fit Soccer Cleats (Boots) - Nike CTR360

I have wide, flattish, feet and love to play soccer - and this can be a problem when you're feet are size 12 1/2 to 13.

I've taken to wearing turf shoes the past two seasons because they're so much more comfortable than regular cleats - even Copas (which stretch well, but have a really narrow plate) are a problem as they are fine during the game but the next day my feet really hurt...

Luckily I was browsing Nike's website to see if they had any wide-fit boots now (almost nobody does) and lo and behold - they have a customizeable boot called the Trequartista III that comes in a wide fit.

Nike CTR360 Trequartista III FG iD (Wide) Men's Firm-Ground Soccer Cleat

You have to order direct from Nike's online store, and they're not cheap at $135, but you get to customize the studs, plate, upper, tongue, laces, et cetera - but most importantly they have 12 1/2 WIDE fit.

Thank God...  Sadly you have to wait 25 days while they make them and ship them to you though...

Mine will look like this:


Let's hope they fit well :).

BTW, the link to order is:

Thursday, January 9, 2014

SkyDrive is a pretty cool free app with a fair amount of free storage, but I really don't want to sync files by dumping them in the SkyDrive folder - so...

I tried simply making a soft link to the folders I wanted sync'd on my drives and it turns out that it works just fine.

mklink /D "C:\SkyDrive\MyFolder" "C:\SomeLocation\MyFolder"

You need to be running a command shell with Administrative privileges before you execute that.

The example above presumes that your SkyDrive folder doesn't already have a "MyFolder" link or folder in it, and when it runs, a soft symbolic link will be created in the SkyDrive folder that resolves to the actual folder location outside of the SkyDrive.

I currently share files between two PCs and an OSX box (yes, SkyDrive is on OSX too) this way before they qualify to be put into source control...

Tuesday, December 24, 2013

English subtitles in English soundtrack for foreign dialogue using Handbrake

I have backed up most of my video collection to a central server in my house, and I usually use AnyDVD HD and CloneDVDMobile together to do my rips; however, CloneDVDMobile has very limited support for subtitles (which I only noticed after going through dozens of my DVDs and doesn't support BluRay at all.

To get around these two issues I use Handbrake.  Using Handbrake to rip from BluRay is another topic; however, using it to effectively pull subtitles that are supposed to be shown in the English only soundtrack can be a pain, so since I've just re-figured this out again for probably the 3rd time - I'm posting it here so I can find it myself later...

Under subtitles, choose to Add and usually select the first English audio track (you may have to try others), then check 'forced only' and 'burn in' and usually you'll get the results you would get from simply playing the movie in your bluray/dvd player.

Tuesday, December 10, 2013

Unity3D 2D UI Click-Through Issues

I have message box and dialog box classes for use in Unity3D that need to act 'modally' (but not truly modal) at times, and one of the problems I've had was preventing the mouse-clicks/touches from hitting controls under the controls in the message/dialog boxes.

You'd think that the Unity3D system would already take care of this, but apparently there is some behind the scenes issue that is non-trivial to resolve (otherwise the Unity3D devs would have knocked this out a looooong time ago.)

Anyhow, I found a simple solution today that works for me (until I find it fails on iOS - fingers crossed that it doesn't!)

When my OnGUI call gets to my message/dialog box, the message/dialog box simple creates TWO full screen transparent GUI.Window objects.  The first one calls an empty method, the second one calls the method that draws the controls of the message/dialog box.

I'd tried this previously, but only created one GUI.Window - hoping (vainly) that having the window under the message/dialog box would prevent clicks from making it through.  Oddly enough, it sort of worked, it prevented clicks that were on the message/dialog box controls from going through, but you could still click anywhere on the rest of the screen and cause havoc...

Anywho - I'll have to test have badly this affects performance (it shouldn't really as the both windows entire areas have an alpha of 0.0.)

Monday, December 9, 2013

Sharing C# Source Code With A Unity3D Project

I ran into some issues recently trying to share some common networking and data classes between a client application, a middleware ASP.NET server, and a configuration/server management tool.  All three of them needed to be able to serialize/de-serialize the same XML data; however, Unity3D does not currently support (natively) the ability to reference source code files outside of its project directory structure.

The easy solution to this on Windows is to create a symbolic link, and it works nicely.

I'll be revisiting this problem when I go to build on OSX (I presume that I'll be messing with my samba conf) and there are ways you can trick your source control system into accomplishing this (but it's really hacky) - so this isn't a panacea for the issue.

Hopefully the Unity team will introduce its own linking system that handles this (if Mono doesn't already have it...)

Worst case I'll be writing some file synchronization scripts that trigger the Unity editor to copy from the common direct (which is problematic if I make changes in Unity - but hopefully I can avoid that.)

Sigh...

Wednesday, December 4, 2013

Recently converted an ASP.NET Web Site project to a Web Application project...

...because I really need to use shared/common sources for 3 inter-related projects and you need a Web Application to do it (because Web Site projects do not let you link to source files, just copy.)

Anywho - I converted, built, tested, deployed, crashed.  Turned on detailed errors, zilch.  Enabled .NET error page information.  Bingo, "Default.aspx.cs could not be found."  What?

I FTP in, look at the directory structure and see that the bin folder does contain the DLL it should.  Spend a half hour wondering what exotic setting I'd forgotten to configure.  Cursed Microsoft for a little bit.

Suddenly I remembered something rather important.  When you're using a pre-compiled version of your project (as a Web Application generally is), you don't use the CodeFile attribute in your Default.aspx html code.  You use CodeBehind.

CodeFile instructs the webserver serving the page to use the JIT compiler.  CodeBehind instructs the compiler on your dev box where to find the class it needs to shove into the DLL.

So, yet again, it was all my #F$()ing fault.  Sigh...

Monday, November 4, 2013

Flickering running Rise of Nations on Windows 7 - Intel HD 4000 Graphics

I played with the old (circa 2003 iirc) game Rise of Nations this weekend while waiting for someone to reply to e-mail inquiries and I ran into a strange flickering problem that nobody seems to have reported on the interwebs, so I thought I would post the solution I found.

Editing the ron2.ini file and setting ForceAGPVBs=1 resolved the issue for me.  Previously the graphics had flickered heavily - especially relating to text boxes.  None of the older solutions (expading resource windows or disabling vsync) worked for me, but this did.  BTW, this was on a 2012 Mac Mini running Windows 7.

Thursday, April 18, 2013

Passing a structure containing a float array from C# to a C++ DLL

For a struct defined in C++ as:

struct MyStruct
{
    float m_aFloatArray1[4];
    float m_aFloatArray2[4];
    float m_aFloatArray3[4];
};

And you want to simply pass the struct from C# straight into C++, you would define the struct on the C# side as:

[StructLayout( LayoutKind.Sequential )]
public struct MyStruct
{
    [MarshalAs( UnmanagedType.ByValArray, ArraySubType = UnmanagedType.R4, SizeConst = 4 )]
    public float[] m_aFloatArray1;
    [MarshalAs( UnmanagedType.ByValArray, ArraySubType = UnmanagedType.R4, SizeConst = 4 )]
    public float[] m_aFloatArray2;
    [MarshalAs( UnmanagedType.ByValArray, ArraySubType = UnmanagedType.R4, SizeConst = 4 )]
    public float[] m_aFloatArray3;
}

Note that this approach only works for fixed size arrays (otherwise things get hairy.)

Tuesday, March 19, 2013

Consuming Google Translate API v2 with C#

I spent far too much time today figuring this out (never having dealt with JSON or Google APIs before.)

It is very simple to use Google's translate services (provided you have an API key), but in the interest of sharing (and avoiding some little oopsies I hit today - such as unwrapping certain characters) here's a crude and simplified version of what I implemented.

BTW - Please note that I am using the JavaScriptSerializer below, which means that although I use a data contract (for other reasons) this particular deserializer maps by property name; ergo, the class member names MUST match the JSON property names.


[DataContract]
public class GoogleTranslation
{
    [DataMember( Name = "data" )]
    public Data Data { get; set; }
}

[DataContract]
public class Data
{
    [DataMember ( Name = "translations" )]
    public List Translations {get; set;}
}

[DataContract]
public class Translation
{
    [DataMember( Name = "translatedText" )]
    public string TranslatedText { get; set; }
}


The 3 classes above are going to be used to deserialize the returned JSON data in the method below.  BTW, you need to add three references to your project (at least, if you use the code I supply below you do - there are surely many alternatives.)

     System.Web
     System.Web.Extensions
     System.Runtime.Serialization

Sorry I didn't spend the time formatting this code (I just dumped it in) - I may do so later as it is late and I have miles to go before I do anything resembling sleep.



public string GoogleTranslate( string in_strFromLanguageCode, string in_strToLanguageCode, string in_strString )
{
    string l_strKey = "YOUR_API_KEY_GOES_HERE";
    string l_strURL = "https://www.googleapis.com/language/translate/v2?key=" + l_strKey + "&q=" + in_strString + "&source=" + in_strFromLanguageCode.ToLower() + "&target=" + in_strToLanguageCode.ToLower();
    string l_strTranslation = "";

    try
    {
        WebClient l_oWebClient = new WebClient();
        string l_strResult = "";

        //Notify the webclient we're expecting UTF-8
        l_oWebClient.Encoding = System.Text.Encoding.UTF8;
        l_strResult = l_oWebClient.DownloadString( l_strURL );

        //Unwrap special characters
        l_strResult = HttpUtility.HtmlDecode( l_strResult );

        //Deserialize JSON
        JavaScriptSerializer l_oSerializer = new JavaScriptSerializer();
        GoogleTranslation l_oTranslation = l_oSerializer.Deserialize( l_strResult );

        l_strTranslation = l_oTranslation.Data.Translations[ 0 ].TranslatedText;
    }
    catch( WebException )
    {
        //Evaluate status code
    }

    return l_strTranslation;
}


Now, there's lots of things missing you'd use in real production code (such as any basic error handling) - but that should be enough to get you rolling.

Enjoy!

Wednesday, February 13, 2013

Hmmm... New motherboard, Windows 7, low audio volume...

...after thinking too much about solving this issue with my fancy 'everything AND the kitchen sink" motherboard - it turns out that listening with headphones when your HD audio thinks you're plugged into a 7.1 surround sound system (no idea why it defaulted to this) results in really low 'max volume.'

Settings it to 'stereo' nearly blew my head off (since I was playing some Buckethead on full blast...)

Wednesday, August 29, 2012

If your iTunes songs are getting cut off...

...you may have a very simple solution.

I just moved my iTunes library to a new machine and found that a huge number of my ITMS purchased sons would cut off at odd points in the song (but for songs from the same album THEY ALWAYS CUT OFF AT THE SAME PLACE - oh iTunes how I sometimes hate you... ;) )

Anyhow, I chanced upon a solution to this (which I gleaned from a post 30 posts deep in an apple forum) which requires you to create a new music library and simply import your previous library into it.  This sounds complicated but it is, in fact, quite simple.

To do this, I held down the shift key (either one should work) when starting iTunes and iTunes gave me a little dialog allowing me to create a "new Library" which I did right next to my old one.  Then, after iTunes opened onto this new and empty library, I simply chose File|Library|Import Playlist and located my old library's base "iTunes Music Library.xml" file and imported that - bingo, it imported everything from my previous library.

After validating that this worked, and that my music was now playing properly, I consolidated all my files into my new library folder.

Hope this helps someone the way it helped me.

By the way, I believe that on OSX you hold down the option key when starting iTunes to replicate this approach.

Monday, June 25, 2012

Word 2010 Table Of Contents nightmare...

...I need to preface this with "I am a total moron when it comes to anything other than basic Word or other Office product features."

I have a large document that is an API reference manual (around 200 pages) and I am updating it every so often as new releases are made available.

One of the problems I've always had is that my very carefully formatted and styled Table of Contents tends to get hosed up every time the page numbers need to update (which seems nonsensical to me considering that they're chained to particular styles in the document and should, therefore, update auto-magically.)

What always seemed to happen when choosing "update fields" is that the entire table would get reformatted.

Well, I found another way to trigger updating the fields in the TOC but simply by clicking in the TOC and pressing F9 which brought up a little dialog that let me specify to ONLY update the page numbers and bingo - updated TOC.

I'm sure this is dumb, and I should have found this 5 minutes in, but just in case there's another one of me out there - here you are my fellow nin-cow-poop (to quote Bugs.)

Saturday, June 16, 2012

C# calling a C++ DLL, things NOT to forget

Whatever you do, no matter how rusty you are at doing this, remember to set the calling convention on your DllImport statements.  I spent two hours last night trying to track down a bizarre AMD ATI driver bug in a 3D rendering dll I was writing - it only occured when the platform was x86 and the requested feature level was DirectX 11, all other feature levels worked fine and everything worked fine on x64 from the get go.)

I went to bed frustrated (and tired - it was 1:45AM and I wasn't planning on that last night - lol) and woke up annoyed, and after finding very little mention of the problem on the inter-tubes figured I was doing something stupid (since it is unlikely I'm the one discovering a 'new' problem with an ATI driver and Direct3D.)  As usual, assuming I screwed up has paid off in spades.

It turns out that I was suffering some sort of stack corruption that was screwing up the creating of devices and swap chains in DirectX 11 and the root cause was my ASSumption about the default calling convention of a DllImport.  I figured it was cdecl, and my C++ dll is sprinkled with __cdecl export definitions; unfortunately, (and here's where I wasn't thinking very well) the default convention is OF COURSE WinAPI.

Once I specified the calling convention my mysterious and bizarro AMD driver issues suddenly vanished, and I have now moved on to more mysterious and problematic bugs.