Could not load file or assembly grasshopper. Error with assembly

Currently I am creating a new assembly using visual studio. Let’s call this assembly A. I reference assembly B to the assembly A project. However I could not load assembly B in grasshopper. It keeps reporting the same problem.

Object: AssemblyA (level 1)
Exception has been thrown by the target of an invocation.

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

I have read all other related grasshopper forum topic related to this error and could not find my own solution. I have also tried the following:

  1. Re-opened my Visual Studio and project.

  2. Removing extra references in the code

  3. Copying both AssemblyA and AssemblyB .gha to my /Libaries/ directory.

  4. Setting Copy True local of all the references to false.

  5. Deleting .PDBs

  6. Clear all temp files

Thanks in advance

I also make sure that both Assembly A and B .gha or .dll are unblocked. Both assembly are self developed so there is no license issue

If A depends on B, B has the extension GHA rather than DLL and A is loaded first, then it probably won’t figure out that B.gha is the file it needs. The framework looks at a limited set of extensions in a limited set of folders to figure out whether it can find the referenced assembly.

What you can try is set up an AppDomain.AssemblyResolve event handler. This event will be raised when the framework cannot find a needed assembly and it allows you to specify one. I’m not entirely certain this will work if B.gha also needs to be loaded as a plugin in its own right, but I’m hopeful it will.

In the end, the classes and method from assembly B (which the assembly being referenced) could not be in the same class as the component class page (the final page). Creating another class and call the method from another class seems to do the trick