The type initializer for "OpenCV.Net.Native.NativeMethods' threw an exception

1,489 views
Skip to first unread message

Albit Caban

unread,
Jun 14, 2021, 3:44:45 PM6/14/21
to Bonsai Users
Hi!

I suddenly started getting this msg when I try running some cameras on Bonsai: "The type initializer for "OpenCV.Net.Native.NativeMethods' threw an exception". I re-downloaded and used the .exe file as I saw the zip file could introduce this error in a previous comment. Any idea what could be happening? Thank you so much!

-Albit

jonathan...@gmail.com

unread,
Jun 18, 2021, 2:38:19 PM6/18/21
to Bonsai Users
This is a dependency issue, the bonsai executable is looking for a native (written in C/C++) OpenCV dll that it cannot find. The easiest route is usually to nuke your Bonsai installation completely and start over. There are some crazy things that need to be done to make sure all the dependencies for OpenCV get put in the right place using Bonsai's Nuget package manager at its very common this gets messed up. I believe that Goncalo is looking into ways to improve this situation.

Albit Caban

unread,
Jun 18, 2021, 2:45:31 PM6/18/21
to Bonsai Users
Hi! Thank you so much, I have tried a couple of times to completely delete bonsai and re-install it but it seems to not help. I really have no clue what to do. I don't know if maybe it hasn't helped because I have left bonsai workflow files technically on the computer and I should delete those as well. 

jonathan...@gmail.com

unread,
Jun 18, 2021, 3:15:17 PM6/18/21
to Bonsai Users
I think you are on the right track, but its not going to be with the workflow files its going to be in some nuget cache somewhere. E.g. the .nuget hidden folder your user directory. Maybe go in there and delete everything that has bonsai or opencv in it.

Gonçalo Lopes

unread,
Jun 22, 2021, 3:59:05 AM6/22/21
to jonathan...@gmail.com, Bonsai Users
On occasion this might also be an issue with missing VC++ runtime system dependencies. The Bonsai system installer takes care of these, but if you happened to use the portable version you might not have them in the system.

You can try installing Bonsai just once in your system to try out this theory:


--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/ad7a5d5f-638b-4b39-aaa4-2533c0d5fe6bn%40googlegroups.com.

Albit Caban

unread,
Jun 29, 2021, 6:51:34 PM6/29/21
to Bonsai Users
Hi all, thank you for all your help. I still can't seem to shake the error message. I uninstalled bonsai and made sure everything with bonsai and opencv is deleted from the .nuget hidden folder. I installed bonsai once from the link and still have the same error. Any ideas on how to proceed? Thank you so much.

Albit

Gonçalo Lopes

unread,
Jul 4, 2021, 7:48:19 PM7/4/21
to Albit Caban, Bonsai Users
I don't know which version you are running but can you try installing these runtimes for both 32 and 64-bit? Maybe manual installation can solve it.


Hope this helps

Jiaxuan Qi

unread,
Nov 11, 2021, 4:36:13 PM11/11/21
to Bonsai Users
Hi Albit,

Have you got any luck to solve it? I happened to meet the exact same error as you today and wonder if there are any good solutions. Thanks!!

Best,
Jiaxuan

Gonçalo Lopes

unread,
Dec 29, 2021, 8:56:32 PM12/29/21
to Jiaxuan Qi, Bonsai Users
Hi Jiaxuan,

Did you try installing the two runtimes mentioned in my answer? Are you still getting errors after installing them?

Reply all
Reply to author
Forward
0 new messages