Could not load file or assembly grasshopper. Error with assembly

rhinocommon
grasshopper

#1

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.
TargetInvocationException
}

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

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


#2

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


(David Rutten) #3

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.


#4

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