Grasshopper

algorithmic modeling for Rhino

How to use a custom parameter defined in an assembly ... in an other assembly

 

Hi all,

I'm facing the following problem, which really stuck me :

I've created a custom mesh parameter within a C# project called "Gridshell". This project gives geometric tools to generate gridshells on nurbs surfaces. It references GH_IO.dll, Grasshopper.dll and Rhinocommon.dll.

Custom Class : GS_Mesh

Custom Type : GHType_GSMesh : GH_Goo<GSMesh>

Custom Parameter : GHParam_GSMesh : GH_Param<GHType_GSMesh>

Now, i'm developing a set of structural analysis components to relax gridshells. Those components are grouped in a new project called "Marsupilami".

Naturally my components would eat GS_Mesh objects and relax them. My project references GH_IO.dll, Grasshopper.dll, Rhinocommon.dll and Gridshell.dll.

But I can't build my code because I get the following error, where I try to instantiate a GHType_GSMesh object  :

Errorr    3    The type 'Grasshopper.Kernel.Types.GH_Goo`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Grasshopper, Version=1.0.0.20, Culture=neutral, PublicKeyToken=null'.    C:\Documents and Settings\l.dupeloux.TESS\Mes documents\Dropbox\Dev\Marsupilami\1 - visual studio\Marsupilami\GHComponents\GHComponent_GSMeshRelax.cs    97    13    Marsupilami

I've checked many times but the assembly seems to be referenced in both projects (local copy = false) in the required version (1.0.0.20).

Do you have any idea how to solve this problem ?

Many Thanks

Lionel

 

Views: 1008

Replies to This Discussion

I've found this, but it doesn't work for me :

http://aftabkalhoro.wordpress.com/2011/08/03/the-type-is-defined-in...

Lionel

Hi Lionel,

You will have to import the namespace in which you declared your custom class, for exemple:

using Gridshell.Types;

Then you should be able to use your class, and if you have an empty constructor set in your class there is no reason you could not use it like that:

GSMesh MyMesh = new GSMesh();

or else,

GSMesh MyMesh = null;

I hope it helps,

T.

Thanks Thibault, but the problem I face is more tricky than that. It's more or less what is described here :http://aftabkalhoro.wordpress.com/2011/08/03/the-type-is-defined-in...

But the proposed solution doesn't work in my case ...

It might be something about grasshopper.dll for V4 versus V5. Any other idea ?

Lionel

Did you try to clean the solution, then to rebuild the gridshell lib, then the marsupilami lib (with  copy local = false on all the references) while having the rhino and GH closed?

You maybe have a mismatching local copy of the dll in the compilation folder, maybe you can wipe it manually.

Ok, I did something similar for both VS projects, after hours of googling :

- uninstall RH4

- clean my solutions

- delete /bin /debug /release folders content

- unreference GH_IO.dll, Grasshopper.dll, Rhinocommon.dll

- build projects

- reference back GH_IO.dll, Grasshopper.dll, Rhinocommon.dll (those in the Grasshopper for RH5 folder). Make sure to set copy local to "False".

- rebuild the projects

I finally got rid of this message. But ... it's not working anyway. Now :

- I can reference gridshell.dll in marsupilami

- I can declare objects from grishell library within marsupilami (for example this line works fine : GSMesh mygsmesh;). It means VS finds my assembly and is able to read in it.

- but I can't instanciate my classes (for example this line leads to an error : GSMesh mygsmesh = new GSMesh();) The corresponding error is "Could not load file or assembly Gridshell.dll or one of its dependencies".

I don't know what's the cause of this error.

I bypass the problem by writing my component in gridshell while calling marsupilami dll, instead of writing it in marsupilami while calling gridshell dll.

In this way, everything works fine. Both libraries work fine, independently. But in the other way, it's a mess I don't understand.

Any idea to solve this ?

Thanks again for reading and helping,

Cheers,

Lionel

Hi Lionel,

It could be a problem of class hierarchy between the dlls, you will have to check that your Gridshell class is not calling anything from Marsupilami or another class that is supposed to rely on something coming after Gridshell.dll

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service