How to address classes functions methods from external dll's - Grasshopper2024-03-29T06:10:44Zhttps://www.grasshopper3d.com/forum/topics/how-to-address-classes?commentId=2985220%3AComment%3A44760&feed=yes&xn_auth=noHi, I keep receiving "Unable…tag:www.grasshopper3d.com,2010-06-17:2985220:Comment:722012010-06-17T12:02:23.492ZYing Tsai Chenhttps://www.grasshopper3d.com/profile/YingTsaiChen
Hi, I keep receiving "Unable to load one or more of the requested types" in the C# GH component, when i try to load a external .dll file in the current built grasshopper.. but the previous old version GH can take the same dll file.. can anyone give a hand for this? many thanks..
Hi, I keep receiving "Unable to load one or more of the requested types" in the C# GH component, when i try to load a external .dll file in the current built grasshopper.. but the previous old version GH can take the same dll file.. can anyone give a hand for this? many thanks.. Though it said Unable to load…tag:www.grasshopper3d.com,2010-06-09:2985220:Comment:706702010-06-09T13:01:42.676Zpanhaohttps://www.grasshopper3d.com/profile/panhao
Though it said Unable to load one or more of the requested types,the VB component worked very well.<br />
A window with two buttons appeard.
Though it said Unable to load one or more of the requested types,the VB component worked very well.<br />
A window with two buttons appeard. Daniel:
I had the same probl…tag:www.grasshopper3d.com,2010-02-12:2985220:Comment:489502010-02-12T21:45:07.585ZJason Fleminghttps://www.grasshopper3d.com/profile/JasonFleming
Daniel:<br />
<br />
I had the same problem. When you open the c:\windows\assembly folder, a shell extension is used to display the assemblies (instead of windows explorer displaying the actual files). This issue, and how to get around it, are addressed <a href="http://blogs.msdn.com/johnwpowell/archive/2009/01/14/how-to-copy-an-assembly-from-the-gac.aspx" target="_blank">here</a>.<br />
<br />
I used Option 3 and was then able to locate and referenced the Excel .dll from Grasshopper.<br />
<br />
Hope this helps.
Daniel:<br />
<br />
I had the same problem. When you open the c:\windows\assembly folder, a shell extension is used to display the assemblies (instead of windows explorer displaying the actual files). This issue, and how to get around it, are addressed <a href="http://blogs.msdn.com/johnwpowell/archive/2009/01/14/how-to-copy-an-assembly-from-the-gac.aspx" target="_blank">here</a>.<br />
<br />
I used Option 3 and was then able to locate and referenced the Excel .dll from Grasshopper.<br />
<br />
Hope this helps. Sorry to jump in here but:
I…tag:www.grasshopper3d.com,2010-02-10:2985220:Comment:486062010-02-10T21:39:29.204ZDaniel Caserta Segraveshttps://www.grasshopper3d.com/profile/DanielCasertaSegraves
Sorry to jump in here but:<br />
I can't seem to reference an assembly by the method described by David above.<br />
I'm trying to reference Microsoft.Office.Interop.Excel. The dialogue box does not respond to 'Open' or double-clicking, though it is visible as a *.dll.<br />
.gha's do seem to work.<br />
Am I missing something?<br />
Working with version 060059<br />
<br />
Thanks!
Sorry to jump in here but:<br />
I can't seem to reference an assembly by the method described by David above.<br />
I'm trying to reference Microsoft.Office.Interop.Excel. The dialogue box does not respond to 'Open' or double-clicking, though it is visible as a *.dll.<br />
.gha's do seem to work.<br />
Am I missing something?<br />
Working with version 060059<br />
<br />
Thanks! Hi Hans,
I noticed this too.…tag:www.grasshopper3d.com,2010-01-18:2985220:Comment:449622010-01-18T10:52:24.264ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
Hi Hans,<br />
<br />
I noticed this too. No idea what the problem is yet. It is me who is supposed to look at the LoaderExceptions I think.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia
Hi Hans,<br />
<br />
I noticed this too. No idea what the problem is yet. It is me who is supposed to look at the LoaderExceptions I think.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia EventsExampleProject.zip cont…tag:www.grasshopper3d.com,2010-01-16:2985220:Comment:447632010-01-16T18:13:11.273ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
EventsExampleProject.zip contains a complete VB class library which has exactly one Form defined. This form contains two buttons and a TextBox, and it adds 3 events to the default list:<br />
<br />
Button1Pressed<br />
Button2Pressed<br />
TextContentChanged<br />
<br />
<br />
Then, the ghx file has a VB component which references this dll (you'll have to fix the reference path). Inside the VB code, there is a Shared, class-level variable called m_form which will contain the currently active instance of that window. It is Shared so…
EventsExampleProject.zip contains a complete VB class library which has exactly one Form defined. This form contains two buttons and a TextBox, and it adds 3 events to the default list:<br />
<br />
Button1Pressed<br />
Button2Pressed<br />
TextContentChanged<br />
<br />
<br />
Then, the ghx file has a VB component which references this dll (you'll have to fix the reference path). Inside the VB code, there is a Shared, class-level variable called m_form which will contain the currently active instance of that window. It is Shared so that it remains alive between different runs of the script.<br />
<br />
The code inside the RunScript method does 3 things:<br />
<br />
1) If the form has been defined in the past (i.e., it is not Nothing), but it is no longer visible, we assume it has been closed and we detach ourselves from this form.<br />
<br />
2) If the form variable is Nothing, we create a new form, we make ourselves aware of the three events and we display the form on the screen.<br />
<br />
3) We read the contents of the TextBox and apply that String to the [A] output.<br />
<br />
Now, there are three more subroutines in this script, all of which are event handlers. Whenever something happens on the form, these functions will get called. One of these functions displays a message box, another one writes something to the Rhino command line and the third one expires the VB Component, which causes the Grasshopper solution to be recomputed.<br />
<br />
<br />
<br />
This is not exactly trivial stuff. And to get it just right (it still feels pretty clunky) I'd have to invest about two days writing more GUI code.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia Hi Hans,
do you want to expi…tag:www.grasshopper3d.com,2010-01-16:2985220:Comment:447602010-01-16T18:05:54.103ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
Hi Hans,<br />
<br />
do you want to expire the current Grasshopper solution based on an external event? I mean, if someone presses a button on a Form which is declared inside a DLL you are referencing from within a VB component, do you want Grasshopper to respond to that?<br />
<br />
If this is the case, you'll have to handle events that are raised by the remote assembly. I'll post an example project and client ghx file here that does exactly this.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia
Hi Hans,<br />
<br />
do you want to expire the current Grasshopper solution based on an external event? I mean, if someone presses a button on a Form which is declared inside a DLL you are referencing from within a VB component, do you want Grasshopper to respond to that?<br />
<br />
If this is the case, you'll have to handle events that are raised by the remote assembly. I'll post an example project and client ghx file here that does exactly this.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia In the menu of the VB compone…tag:www.grasshopper3d.com,2010-01-05:2985220:Comment:426972010-01-05T11:15:30.007ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
In the menu of the VB component, click on Referenced Assemblies... and add a dll file to the list.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia
In the menu of the VB component, click on Referenced Assemblies... and add a dll file to the list.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia Hi Hans,
only Rhino itself i…tag:www.grasshopper3d.com,2010-01-04:2985220:Comment:425492010-01-04T18:16:33.584ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
Hi Hans,<br />
<br />
only Rhino itself is allowed to run code inside MRhinoCommand classes. Anything you put inside the RunCommand() function is off limits for all external access.<br />
<br />
You need to put your algorithms into separate classes and methods, which can be instantiated and called by the code inside a VB component.<br />
<br />
The steps required are:<br />
<br />
- Add a reference to the VB component. At the moment you can only reference dll files, so be sure to compile your plugin to a dll instead of rhp (I can add other…
Hi Hans,<br />
<br />
only Rhino itself is allowed to run code inside MRhinoCommand classes. Anything you put inside the RunCommand() function is off limits for all external access.<br />
<br />
You need to put your algorithms into separate classes and methods, which can be instantiated and called by the code inside a VB component.<br />
<br />
The steps required are:<br />
<br />
- Add a reference to the VB component. At the moment you can only reference dll files, so be sure to compile your plugin to a dll instead of rhp (I can add other extensions easily if this is called for).<br />
<br />
- The namespaces inside that library should now automatically be added the the Imports section of the VB Componentn code editor (this section is collapsed by default, way at the top).<br />
<br />
- Now you should be able to access classes and methods in that dll.<br />
<br />
Be sure to get the latest Grasshopper beta (0.6.0055, from december 31st), as it fixes a problem with loading remote dlls.<br />
<br />
--<br />
David Rutten<br />
david@mcneel.com<br />
Poprad, Slovakia