| Using VISA.NET > API Structure > Resources and Sessions > Keysight.Visa Session Classes |
The following diagram shows the relationships among the classes and interfaces defined in the Keysight.Visa and Ivi.Visa namespaces. Note that the relationships between resource types and message-based vs. register-based sessions are not as intuitive as might appear. For example, TcpipSocketSession derives from MessageBasedSession despite the fact that it is not an instrument session.

There are three ways to obtain a VISA.NET session:
Instantiate a session class directly. This is the simplest approach if you know exactly what session type you need.
Use the Keysight ResourceManager to open a session. You will get a reference to IVisaSession and then you'll cast it to whatever session interface or session class you need. With this method, you'll always get a Keysight session, so you can cast that Keysight session to the desired session class, and you must use the class (rather than the Ivi.Visa session interface) if you want to use Keysight-specific features. Use this method if you are connecting to one of several session classes depending on the instrument address (for example, if you are connecting to an instrument by alias and don't know in advance what bus that instrument will be on).
Use the global resource manager (GRM) to open a session. You will get a reference to IVisaSession and then you'll cast it to whatever session interface you need. With this method, you'll typically cast to one of the Ivi.Visa session interfaces. This method supports interoperating between NI VISA.NET and Keysight IVI.NET.