If you're "hand-tabbing", and which is only driving a soft synth plug-in, then it's unlikely SYSEX is being injected into Sonar during this process and therefore SYSEX is not the culprit in this instance. You need to look elsewhere.
You might want to start a new thread with the title "Play back of MIDI events I created crashes Sonar" or something like that. Then proceed to mention things like your OS and machine specs. Which soft synth plug-in you're using. Whether the soft synth plug-in is 32 bit or 64bit.
I was tackling your original question "Can MIDI (.mid) files have a virus"