fsprojects / IfSharp

F# for Jupyter Notebooks
Other
441 stars 71 forks source link

Using App.config #150

Closed mateuszlewko closed 7 years ago

mateuszlewko commented 7 years ago

Description

I'm looking for a way to use app.config with IfSharp. I've found that when using fsi.exe I just need to copy my app.config and paste it into /usr/lib/mono/fsharp/fsi.exe.config or .../fsiAnyCpu.exe.config (on linux, something similar on windows). This actually works, but unfortunately not with f# notebook. IfSharp still doesn't see configs from app.config. I expected it to work the same way as back-end for notebook session is actually an fsi.exe session (is it?).

Do you know any workaround on how to use app.config in notebook? Where should I put it? I need to use app.config for mysql connector in order to define connection.

Related information

cgravill commented 7 years ago

Yes, there is an fsi shell internally but it's hosted by the F# compiler services which may your issue. We have a launch process IfSharpConsole.exe that Jupyter calls back into you can configure the .config of that ifsharp.exe.config and it'll then be present in the kernel execution.

To demonstrate I read it in Jupyter cell:

#r "System.Configuration"
open System.Configuration

ConfigurationManager.AppSettings.["samplesetting"]

image

That's going to be global over all notebooks which might be what you're after. Does the mysql connector not have someway to configure it in code?

Hope this helps!

mateuszlewko commented 7 years ago

I didn't see that there is an ifsharp.exe.config. It's a bit hacky but sufficient for me to merge this with my app.config. I'm not sure if mysql connector has an option to set its parameters differently. Anyway thanks for help.