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

Csharp for OpenStudio

asked 2015-10-14 08:15:22 -0500

gg_student gravatar image

updated 2015-10-15 07:53:37 -0500

I tried to start a project in visual studio to create different OpenStudio Models based on a database. Therefore I insert the .dlls from the Csharp Folder in the OpenStudio/bin. But this doesn´t work with OpenStudio 1.8.0/1.8.5/1.9.0. I always get an error Message, when I try to create a model or create a runmanager.

When I try to use OpenStudio 1.3.0, I don´t have any error Messages and I can create surfaces etc.. But when I safe the model, it doesn´t exist without sending an error Message. I can´t see if it works.

What could be the mistake of the programm? How can I get the dll work on visualstudio? What can I do, to make the DLL work in Visual Studio?

Now I change the settings of my project and add a reference to the OpenStudio/Csharp/openstudio Folder and the error Message is not shown. BUT when I try to make a simple model with only one construction and building and save this, nothing happens. There is no error message, but the osm. file doesn´t exist. I used this:

OpenStudio.Model model = new OpenStudio.Model();
....
model.save(new OpenStudio.Path(path),true);
edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
3

answered 2015-10-14 09:30:29 -0500

updated 2015-10-15 08:34:13 -0500

Does this answer address your question on how to get the C# DLLs to work in Visual Studio?

UPDATE:

I tested creating a new Model then saving it and it works for me. Make sure you follow the instructions in the linked answer completely. Also, make sure the path variable in model.save(new OpenStudio.Path(path),true); is a valid path. I used "C:\\Users\\UserName\\Desktop\\test.osm" as the string I passed into OpenStudio.Path(). Note that I escaped the path separators and used a file name with osm extension.

edit flag offensive delete link more
1

answered 2015-10-15 14:38:51 -0500

BrianP gravatar image

Make sure you are not mixing architectures (32 bit vs 64 bit). If the version of Open Studio you got the DLL's from was 64 bit, then your C# program has to be 64 bit and vice versa. Don't use the Any CPU option.

I ran into a problem like this when moving to a new version of Open Studio since I inadvertently switched from 32 to 64 bit.

edit flag offensive delete link more

Comments

So this is the way I tried:

  1. Install OpenStudio 64x
  2. Create in the system path variablen: OpenStudio = "C:\Program Files\OpenStudio 1.9.0\bin" and OpenStudioCshapr = "C:\Program Files\OpenStudio 1.9.0\CSharp\openstudio"
  3. Open the Csharp Example from Path = "C:\Program Files\OpenStudio 1.9.0\CSharp\examples\RunManagerExample"
  4. Delete the Reference from OpenStudio
  5. Add new Reference OpenStudio from path = "C:\Program Files\OpenStudio 1.9.0\CSharp\openstudio"
  6. To be sure I copied all dll from "C:\Program Files\OpenStudio 1.9.0\CSharp\openstudio" to the project\bin
  7. start Program
gg_student gravatar image gg_student  ( 2015-10-27 05:20:39 -0500 )edit

it is solved. I had to install Qt and renew the .dll from the programm/bin path with the dll from Qt/plugins/platform

Thank you all for your answers!

gg_student gravatar image gg_student  ( 2015-10-27 06:56:52 -0500 )edit
0

answered 2015-10-15 03:39:05 -0500

gg_student gravatar image

updated 2015-10-15 07:54:13 -0500

Yeah, I try to get the c# DLL work in Visual Studio. There is an explanation in your answer, but it didn´t help. I get the following error Message:

It appears that there was an error accessing the C# SWIG Bindings for OpenStudio. Note that the libraries installed in <installdir>/CSharp/openstudio need to be accessible to this application at runtime, either through the path or in the same directory as the exe. Nothing else will work properly have this point. Error Text: It was tried to import a file in a wrong format. (Except HRESULT: 0x8007000B)

I also tried to copy all of the dll to the project/bin and renew the reference. But the same error occured. What can I do, to make the DLL work in Visual Studio?

edit flag offensive delete link more

Comments

1

Not an answer, please append your initial question if need be.

Julien Marrec gravatar image Julien Marrec  ( 2015-10-15 07:04:43 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

1 follower

Stats

Asked: 2015-10-14 08:15:22 -0500

Seen: 339 times

Last updated: Oct 15 '15