Yeah, many cities in the US had municipal codes prohibiting wearing clothing of the opposite gender (passed between the 1800's and early 1900's). In fact police acting under those laws were what sparked the Stonewall Riots.
Not sure about Canada, but my guess is that even if it wasn't specifically codified it's likely that crossdressing would have been considered under "gross indecency" or similar laws that were also used to prosecute homosexuals. But maybe Canada wasn't nearly as close-minded as the US (wouldn't shock me!).