2

Currently I am creating Grasshopper 3D plugins. I was originally using the C# DateTime library for my time zone needs, but found NodaTime for how extensible and convenient it is. Fell in love immediately.

While creating Grasshopper 3D components, I referenced my assemblies via:

enter image description here

Grasshopper 3D components that are written in C# in Visual Studio compile as class libraries (so there's no console output). So for my preliminary development, I tested NodaTime via a console app. Same configuration, where I used the same method, same assembly, same reference adding -- the console application works just fine. But once I used that method in my Grasshopper component, I get this error:

enter image description here

The things I have personally tried:

  1. Re-opened my Visual Studio and project.

  2. Removing the references and using statements, and adding it again.

  3. Copying [all three] portable .DLLs to my /bin/ directory

  4. Copying [all three] portable .DLLs to my/Libaries/ directory. The /Libraries/ directory are where the Grasshopper 3D component DLLs reside (loaded into Grasshopper for use).

  5. Copy [all of the assemblies] of the NodaTime folder into my /Libraries/ directory.

  6. Setting CopyLocal of NodaTime to true. And to false.

  7. Deleting .PDBs

  8. Suggested by another user, maintained my dependencies via NuGet.

I have indeed read most if not all of the could not load file or assembly Stack Overflow threads, and have checked solutions in the Grasshopper forums.

What could be the issue?

theGreenCabbage
  • 5,197
  • 19
  • 79
  • 169
  • you have the dll from this url http://nodatime.org/downloads/ and the 1.2 release from the zipped file portable folder? may I ask why did you took the portable version and not the regular version? – JP Hellemons Mar 18 '14 at 15:24
  • I have also tried the non-portable version as well :/ I did however have the perception that the "portable" version is precisely for this reason -- is that wrong? – theGreenCabbage Mar 18 '14 at 15:27
  • Ok, and the nuget package? is that an option? because it seems like you did not add a reference in visual studio, or did you? – JP Hellemons Mar 18 '14 at 15:28
  • Hmm. I'm not sure how to use the nuget package version. Is it possible to use this with Visual Studio Express? – theGreenCabbage Mar 18 '14 at 15:29
  • Do you have vs express 2010? or 2012? http://stackoverflow.com/questions/4566908/how-can-i-use-nuget-with-visual-c-sharp-express – JP Hellemons Mar 18 '14 at 15:31
  • Oh nevermind it appears I can use nuget. From my understanding nuget is for this purpose -- consuming assemblies? Is that right? If so, how do I use it to bundle the NodaTime with my DLL? EDIT: OK. I have downloaded and installed NodaTime via nuget: http://puu.sh/7A7NY/78c70daca2.png – theGreenCabbage Mar 18 '14 at 15:32
  • Does it have strong name (nodatime.dll), if so, can you try installing it into GAC ? – Ondrej Svejdar Mar 18 '14 at 15:47
  • Yeah it has a strong name "NodaTime.DLL". According to this article, it seems there's multiple GACs depending on your .NET version: http://stackoverflow.com/questions/6927219/how-to-register-assembly-net-4-0-in-windows-7-gac What's the "correct" path to do so? Since NodaTime is open sourced, I was heavily just considering copying the DateTime class in NodaTime to avoid the dependency issue.. EDIT: Copying it to my GAC seems like it worked! – theGreenCabbage Mar 18 '14 at 15:50
  • @OndrejSvejdar -- this may sound unreasonable, but is it possible to, on compile, have the DLLs/dependencies be consumed, so users don't need to drag and drop things into GACs manually? – theGreenCabbage Mar 18 '14 at 16:05
  • You shouldn't need to do anything with the GAC. I would certainly have *hoped* that just putting them into the Libraries directory would be enough. Can you test this with a different class library - just a dummy one with a single type and a single method? – Jon Skeet Mar 18 '14 at 16:07
  • @theGreenCabbage - I'm not familiar with Grasshopper and how it load dependencies, but GAC is a place which every single .net app checks when resolving assembly dependencies + assemblies in GAC are trusted, so it might be worth a shot to install NodaTime into GAC. – Ondrej Svejdar Mar 18 '14 at 16:11
  • Thanks guys -- since I can finally use NodaTime within my GH scripts, I'm going to fix some of the things I broke while trying to make it work, but I'll be back with answers and findings. – theGreenCabbage Mar 18 '14 at 16:54
  • @JonSkeet It appears simply dragging the `.DLL`s inside the `Portable` folder to my `/Libraries/` folder does that trick. Is NodaTime open-source? Would it be illegal/unethical to take the method I use from NodaTime and put it in my code so when I distribute this application the user doesn't need to drag `NodaTime.DLL` to their `Libraries` folder? – theGreenCabbage Mar 19 '14 at 18:53
  • @theGreenCabbage: Yes, Noda Time is very much open source - see http://nodatime.org. It's under the Apache 2.0 licence: http://www.apache.org/licenses/LICENSE-2.0.html. I *think* you'd be okay with your proposed scheme, but I haven't checked the details of the licence. I'd expect it to basically be as if you bundled the whole DLL. – Jon Skeet Mar 19 '14 at 18:54
  • I'm not sure if I am phrasing this right, but is it possible to "consume" the DLL on compile by adding it as an existing file, kinda like this? http://puu.sh/7Byyx/d3c341f7f5.png The purpose is so users don't need to download/copy NodaTime into their computers; the process to using my app will just be seamless. Of course, I will credit the creators of this great library. – theGreenCabbage Mar 19 '14 at 18:59
  • @theGreenCabbage - You can consider using [ILMerge](http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx) to embed NodaTime in your own assembly. – Matt Johnson-Pint Apr 02 '14 at 05:00

0 Answers0