This is a common problem but there's something I'd call the Feynman solution, as he describes it in several of his lectures (New Zealand QED lecture I think). It's probably applicable to engineering problems as well as to scientific research.
Basically, you have to train yourself not to be emotionally tied to a particular outcome. In Feynman's case, he was talking about scientific theories about the nature of the universe, in the context of a question about whether he 'liked' quantum theory or not. As he put it, you don't get to tell nature how to behave, if you want to understand nature you're going to have to accept that some cherished theory or other that you wanted to be true is going to end up in the garbage bin of failed notions. A corollary is, have something else to get emotionally involved in, family, art, music, etc.
It seems the same with engineering of all sorts. Love that brilliant code you wrote, love that language you've spent all that time learning, love that system you spent a decade building, love those architectural blueprints you slaved over for six months? If it doesn't work for the problem at hand, it's best to toss it out the window and try something else, and getting emotional about it is a mistake. Equivalently, tossing something that works just because you have antipathy towards it for some reason is not the way to go.
Otherwise you end up like all those physicists who hated quantum mechanics so much that they either quit physics or spent decades of effort on futile attempts to refute it.