Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

That is the correct way to use both Path and SqlFile.

Here is a short command line program I used to test this...

using System;
using OpenStudio;

namespace openstudio_test
{
    class Program
    {
        static void Main(string[] args)
        {
            Path path = new Path("C:\\EnergyPlusV8-3-0\\ExampleFiles\\RefBldgMediumOfficeNew2004_Chicago.sql"); // change to path of your sql file
            Console.WriteLine(path.__str__());
            SqlFile sqlFile = new SqlFile(path);
            Console.WriteLine("Everything worked!!");
            Console.WriteLine("Exit program or click any key to exit...");
            Console.Read();
        }
    }
}

I am using OpenStudio 1.8.0.

A few key things, you need to make sure to build this C# project either as x86 or x64 depending on which version of OpenStudio you installed on your machine (32 bit or 64 bit). You can not use the default "Any CPU" for your C# project.

Also you need to have C:\Program Files\OpenStudio 1.8.0\bin;C:\Program Files\OpenStudio 1.8.0\CSharp\openstudio; in your Path in System Variables. This is needed so your C# program can find the various DLLs for OpenStudio and OpenStudio's C# bindings.

Next in your C# project, you need to include the OpenStudio.dll into the References. Do this by right clicking on "References", click "Add Reference...", click the "Browse..." button at the bottom, then navigate to C:\Program Files\OpenStudio 1.8.0\CSharp\openstudio, and "Add" the OpenStudio.dll file.

Now the example code above should work.

If all of this still doesn't work then you may have a permissions issue with the location of the SQL file.