I understand that mosquitoes are the primary vectors of heartworms. Can a dog be infected in other ways?
There do not appear to be any natural non-mosquito vectors of Heartworm (Dirofilaria immitis). In fact it appears there are only about 60 species of mosquito that can be a vector for the parasitic roundworm, this is out of about 3,500 known species of mosquito grouped into 41 genera.
The Wikipedia article was mostly used as reference for the scientific name, it does not clearly state one way or the other on additional vectors. On researching further, the article at parasitesandvectors.com, which taken together with others I found imply "we looked for other vectors and have not found one yet". A person with medical training and equipment could transfer an infection from one dog to another, but that seems outside of the question. If there are host vectors other then the 60/3500 of mosquito species, they either have not yet been found, or they are poorly document and I did not find reference of them. While you are unlikely to find any reliable reference that clearly states "Mosquitoes are the only possible vector", This quote says it as clearly as can be expected.
Dirofilaria immitis (Di) is a filarial worm transmitted by mosquitoes (Culicidae) to carnivores and other hosts.