Export to OPENSTUDIO error "ModelCorePINVOKE"

No, you don’t have to uninstall it. All you need to do is just download the packages from nuget (https://www.nuget.org/api/v2/package/OpenStudio/2.4.0). and change the file extension from “.nupkg” to “.zip” so that you can unzip the files.
You will find three dll files: OpenStudio.dll, openstudio_csharp.dll, and openstudio_translators_csharp.dll inside this package.
Make sure three of them are unblocked.
image

Just copy these three files to CSharp\openstudio folder which is inside your openstudio installation folder (usually C:\openstudio-2.4.0\CSharp\openstudio)

I cannot guarantee it would work on your computer, but worth to try.

1 Like

Thanks MingboPerg.

We’ve tried this option as advised, but still getting the same error. It seems we can’t get OpenStudio to work … the error message is;

“1. Solution exception:The type initializer for ‘OpenStudio.OpenStudioModelCorePINVOKE’ threw an exception.”

@YannisR

I have a suggestion that might be worth a shot. In the past, when my office has run into the OpenStudio.OpenStudioModelCorePINVOKE error, we found (using tools like process explorer) that our program would go to the wrong openstudio.dll (i.e if you have multiple installations or versions) and throw up this error as a result.

So a simple way to solve this is to make sure the system path searches for the openstudio.dll you want, and not going somewhere else. This can be achieved by going into your environmental variables and moving the openstudio directory to the top of your system path list.

Go into windows start tab and search and select “Edit the System Environment Variables” and then:

Environment Variables > Select Path > Edit > Select openstudio directory bin and CSharp folder > Move up

Caveats:

  1. This was for work we were doing with a C# application, and not for Honeybee, but assuming the ironpython interpretor might be searching and importing for a ambiguously referenced openstudio.dll, this should work as well.
  2. Adding the dll path to the top of python’s sys.path is easily done, and I wouldn’t be surprised if Mostapha/Chris already has code doing this internally somewhere in Honeybee. However dll reference errors are notoriously finicky and capricious so I think it’s still worth a shot to manually modify the system path.

Hey guys!
I’ve read all the comments in here, but I am still confused… so, there is no solution for this problem yet?
I am working in 2 different computers: my own and another one from the lab. And I am also getting the mentioned error when I try to use this component.
In my first model, I applied Ideal Loads as my HVAC system. It was able to run in E+, but I couldn’t export my model to OS 2.5 through this component. I got this error message in my computer:

And this one in the computer’s lab (for the same model):
OS_Problem1_Lele

When I tried to import my IDF manually to Open Studio, I got this error:

Then I realized that even though I had set my heating and cooling setpoints in “Set EnergyPlus Zone Thresholds” with some values, in my IDF file they are automatically replaced by 0 (even though I don’t use this component, in my IDF file I get Constant Heating/Cooling setpoint 0). In my simulation through E+, it seems that the program bypasses the constant heating/cooling setpoints and uses a schedule that I created based on my heating and cooling setpoints, using the setpoint temperatures. So, it works.

However, OS doesn’t recognize my IDF file in this way.
I edited manually my IDF, replacing the 0s with some values for constant cooling/heating setpoints, and then OS was able to load my IDF.

So, is there a problem with this “Set EnergyPlus Zone Thresholds” component? It seems that it’s not being read in my case… Or, should HB always automatically set constant cooling/heating setpoints to 0?
Does it have something related to “Export to OS” component not working?

In order to assign another HVAC system to my model, I need to be able to export my model to OS, right? I’ve tried to run a simulation with a Fan Coil + DOAS system through HB, but the “Run E+” component gives me a message saying that it automatically replaced my HVAC with Ideal Loads and that if I needed to use another system, I should be able to export it to OS. So, is there another way I can get this HVAC system working? Or fix “Export to Open Studio”…

OS_Problem4_Lele

@ligiana.fonseca ,

  1. Yes, you need to use export to OpenStudio cponeny to have HVAC systems exported.
  2. OpenSudios’s IDF import only brings in some of the features from the idf like geometry and constructions. It strips out all HVAC systems and thermostats
  3. The PINVOKE error is an issue that exists on OpenStudio team’s end and you can see a lot of github documentation about it. If it was something that we had the power to fix, you can bet that we would have addressed it already. We’ve gotten OpenStudio team to say that they’ll make a utility that installs with OpenStudio to help diagnose the issue.
  4. You see on your second computer that you don’t get the PINVOKE issue because this issue only affects a small percentage of computers. The reason why you get an error there is because of a mismatch between the version of your Honeybee_Honeybee and the OpenStudio component. If you can’t solve it on your own, open a separate issue than the one here since that error has nothing to do with PINVOKE.

Thank you very much for the explanation, @chris :smiley: ! I thought that some of the colleagues suggestions might work, but there were so many. I’ll try to make the computer with the ‘isPlenum’'s error work.

Hi there, apologies for the radio silence. We have tried all the above but nothing seems to work.
We also tried a fresh installation of both OpenStudion 2.5.0 and 2.5.1, on a brand new machine, which also didn’t work. The PINVOKE issue persists.

Has anyone ever managed to run openstudio V2.5.0 (i.e. E+ V8.9.0) through HoneyBee?

Hi again,

As means of update on this, we’ve managed to bypass the PINVOKE issue by downgrading to E+ version 8.6 and OpenStudio version 1.14.

There seems to be an issue with E+ version 8.9, which is included in OpenStudio 2.5.0.

Hope that helps.

I’m perpetually confused when it comes to which versions of which programs are supported.
Seems like @devang is running an older version of E+ but a newer version of OS:

Honeybee supports OpenStudio 2.5
There’s no need to install EnergyPlus once you install OpenStudio.

1 Like

I just wanted to make a (hopefully useful) conclusion here based on all of this discussion. Given what people have tried here and my personal experience teaching HB energy model workflows, it seems very clear that certain versions of OpenStudio are less prone to the PINVOKE error than others.

Notably, @mostapha and I have taught several workshops with OpenStudio 2.4 and we have yet to encounter an PINVOKE error with any of the participants. So this seems to be a more stable version.

All of this said, the discussion here is evidence that some people still experience the PINVOKE error in OpenStudio 2.4 but, for these cases, it seems that OpenStudio 1.14 is able to run without the PINVOKE error.

While this isn’t a perfect solution, it seems like the best that we can offer now until OpenStudio team figures out what is causing this issue.

4 Likes

http://hydrashare.github.io/hydra/viewer?owner=chriswmackey&fork=hydra_2&id=Microclimate_Map_-_Simple&slide=0&scale=1&offset=-16.380859375,-22.50505632365224

for this example file i need openstudio i have latest version installed but same PINVOKE error. After reading your comment uninstalled latest and installed old version as mentioned but after that, the file says no Openstudio found even though when i have old one installed. Any idea what to do now.

Regards,

@Missi ,

See here: How to get Honeybee Legacy working with OpenStudio 3.0

You definitely don’t want to go all of the way back to OpenStudio 1. I suggest either OpenStudio 2.9.1 (if you want something that works out of the box) or OpenStudio 3.0.0 (if you want the latest and greatest and are willing to follow the steps in the link aobve)

1 Like

Thanks @chris installation issues solved.

Now new problem. Is this

~M

You are using an old version of the plugin that is incompatible with OpenStudio 3.0. Update your installed version of Ladybug Tools from the one this past August.

1 Like

Actually this issue is solved by @devang reply some where in old thread. I need to move my .epw file to C file folder where Ladybug file is there. Thanks

P.S. All my plugins where latest. Except one as suggested my your instruction manual

I confirm this statement, openstudio 2.4 doesn’t have this problem

Same here, 2.4 works for me without issues. In case anyone is having trouble finding the older version to download: https://github.com/NREL/OpenStudio/releases/tag/v2.4.0

Hi,

I recently met the same issue of “1. Solution exception: The type initializer for ‘OpenStudio.OpenStudioModelCorePINVOKE’ threw an exception.” when installing LB legacy version with Openstudio 3.0.1.

My solution is to get an OS file and set the default app to be OS, then the issue disappears.

Cannot guarantee it works for everyone, but it at least works for me.

@HAOBOLIU hi dear , could you please define this step in detail ,it would be more helpfull