locked
Is it possible to inject other dlls RRS feed

  • Question

  • User47311 posted

    Hello I was wondering if it's possible to add/inject other dlls. Lets say I would like to do a "workbook" on 3rd party dll

    Thursday, April 28, 2016 11:34 AM

Answers

  • User73391 posted

    Yes, in addition to nuget packages, you can reference any assembly on your file system using #r "path/to/assembly.dll".

    However, in 0.8.0 we broke this a bit. It will be fixed in the next release, but for now you can save your workbook somewhere, put the assembly you want to reference in the same directory as the workbook, and then reference using #r assembly.dll.

    If you are saving the workbook for the first time, you'll need to close and reopen it for the workbook to know how to find the assembly.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, April 28, 2016 7:55 PM

All replies

  • User73391 posted

    Yes, in addition to nuget packages, you can reference any assembly on your file system using #r "path/to/assembly.dll".

    However, in 0.8.0 we broke this a bit. It will be fixed in the next release, but for now you can save your workbook somewhere, put the assembly you want to reference in the same directory as the workbook, and then reference using #r assembly.dll.

    If you are saving the workbook for the first time, you'll need to close and reopen it for the workbook to know how to find the assembly.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, April 28, 2016 7:55 PM
  • User11137 posted

    Hi, I figured that much out for WPF workbooks, but am trying the same for Android, and while it "appears" to work, in that I get intellisense for the Assembly, I suspect it isn't actually prepping that dll in the patch it applies to the running android app, because as soon as I try to touch one of the types in the loaded assembly, bad stuff happens.

    Thursday, April 28, 2016 9:03 PM
  • User73391 posted

    Correct, this is not supported yet for Android, or for iOS on Windows.

    Thursday, April 28, 2016 9:06 PM
  • User11137 posted

    Specifically, if I try to construct a type from that assembly, the REPL loop just hangs. And if I try to do something along the lines of var type = typeof(SomeTypeFromTheAssembly).Name; I get an interesting stack trace: FileNotFoundException: Could not load file or assembly '/Users/myusername/Documents/MyDll.dll' or one of its dependencies at (wrapper managed-to-native) Sbject System.Reflection.Assembly.LoadFrom (bool) at Assembly System.Reflection.Assembly.LoadFrom (string assemblyFile) at Assembly Xamarin.Interactive.Scripting.ScriptAssemblyContext.HandleAssemblyResolve (object sender, ResolveEventArgs args) at Assembly System.AppDomain.DoAssemblyResolve (string name, Assembly requestingAssembly, bool refonly) at void System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<<>d0> (ref <>d0 stateMachine) at Task . () at Task . (object[] submissionArray) at void Xamarin.Interactive.Scripting.ScriptExecutionContext.c__async0.MoveNext ()

    I'm not sure if that code is running in the context of the REPL client?

    Thursday, April 28, 2016 9:06 PM
  • User11137 posted

    Darn, any work around in the short term? Or is this just a wait and see?

    Thursday, April 28, 2016 9:06 PM
  • User73391 posted

    No, but it's coming very soon.

    Thursday, April 28, 2016 9:08 PM
  • User11137 posted

    Thanks, I'll satisfy myself with messing around with the WPF in the short term :)

    Thursday, April 28, 2016 9:09 PM
  • User11137 posted

    BTW, on the subject of getting the dlls via nuget packages, it would be nice if it supported a local nuget repository?

    Thursday, April 28, 2016 9:10 PM
  • User73391 posted

    Good idea, we should add support for custom and local repos.

    Thursday, April 28, 2016 9:11 PM
  • User337 posted

    @SandyArmstrong Any news about custom and local repos?

    Thursday, February 16, 2017 7:32 PM
  • User73391 posted

    @AndreasKlapperich none yet! We are working on some nuget improvements though, so I'll keep it in mind.

    Thursday, February 16, 2017 7:36 PM