Open MAX (Measurement & Automation Explorer), expand Devices and Interfaces>Ports and verify that Com1 is listed. The error code means that the session or reference is invalid. The other way to check is to click the little arrow on the right side of the VISA Resource Name. All valid VISA resources show be displayed. If the port is not listed, in MAX try View>Refresh from the top menu and see if the port is listed. You can also expand the Software section in MAX and verify that NI-VISA is installed.