Compilation error

used Source file

Uploading: Error reporting interface.png…
he VS file I am using is officially provided, but an error occurred during compilation in VS. What is the reason? Thank you.

Hello @曹梓睿,

I could not reproduce the error.

After downloading the zip-archive from 3.5: Adding Functionality to a GH Component - Scripting Guide 2.2.0, the VS-project compiles without issues on my machine.

What is the exact error message and identification number that you get?

– Clemens

Message=未能加载文件或程序集“Karamba3D, Version=, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。系统找不到指定的文件。
在 TensionElim.TensionElimComponent.RegisterInputParams(GH_InputParamManager pManager) 在 C:\Users\Administrator\Desktop\TensionElim\TensionElim\TensionElimComponent.cs 中: 第 28 行
在 Grasshopper.Kernel.GH_Component.PostConstructor()
在 Grasshopper.Kernel.GH_Component…ctor(String name, String nickname, String description, String category, String subCategory)
在 TensionElim.TensionElimComponent…ctor() 在 C:\Users\Administrator\Desktop\TensionElim\TensionElim\TensionElimComponent.cs 中: 第 16 行

Error loading gha file.
Object: TensionElimComponent (level 1)
The target of the call encountered an exception.

Object: TensionElimComponent (level 2)
Could not load the file or assembly ‘Karamba3D, Version=, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the specified file.

i 'm sorry! I tested the following again, and VS2022 compiled the gha file without any issues. I can obtain the gha file, but the generated gha file reported an error when loading in Grasshopper.

TensionElim.gha (8 KB)
GH_Load_Ex.txt (355 Bytes)

Did you place ‘TensionElim.gha’ in the installation folder of Karamba3d (e.g. C:\Program Files\Rhino 7\Plug-ins\Karamba)?
– Clemens

Yes, I have placed this gha file in this path, but there are still loading errors

I recorded a small video of the operation steps. Could you please help me take a look? VS2022 can compile gha files, but there will be an error when loading in Grasshopper. Thank you very much!

I think I know where the problem lies: you installed Karamba3D via YAK, so it resides in ‘…AppData/Roaming/…’. The post-build event in the VS project however copies the compiled .gha-file to ‘C:\Programs\Rhino7\Plugins\Karamba’ which is the default installation path when using the Karamba3D msi-installer. Try to change the latter path to where YAK placed the Karamba3D-files.

I created a new issue regarding this: REQUEST: Visual Studio Scripting Examples: copy files to Karamba3D installation folder · Issue #69 · karamba3d/K3D_NightlyBuilds · GitHub. Thanks you for your patience!

– Clemens

After changing the path according to your suggestion, the gha file can now be loaded correctly. Thank you.