dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.89k stars 387 forks source link

how to add framework reference? #861

Open Spongman opened 4 years ago

Spongman commented 4 years ago

how do you add a framework reference, similar to the following .csproj line:

    <FrameworkReference Include="Microsoft.AspNetCore.App" />

?

The following code block

void F(Microsoft.AspNetCore.SignalR.Hub h) {}

Gives the following error:

The type or namespace name 'Hub' does not exist in the namespace 'Microsoft.AspNetCore.SignalR' (are you missing an assembly reference?)

With .csproj you don't need an assembly reference, the above FrameworkReference element includes the SignalR dlls.

jonsequitur commented 4 years ago

This isn't currently supported but you should be able to reference the package directly using #r nuget.

dsyme commented 3 years ago

See also https://github.com/dotnet/fsharp/issues/8688

jonsequitur commented 3 years ago

Also possibly related: #890

fwaris commented 3 years ago

This is starting to affect my current work. Mostly I need to perform visualizations on data, e.g. MSAGL graph viewer that requires Windows Forms.

Priority will be appreciated.

Faisal

jkone27 commented 2 years ago

Any updates around framework reference, isn't this useful also for aspnetcore apps? cheers

nycdotnet commented 1 year ago

It seems like this does work now, but it's not documented here.

Example: create a brand new notebook, with a C# block with the following content only:

using System.Net.Http.Json;

When you run it, it will return:

Error: (1,23): error CS0234: The type or namespace name 'Json' does not exist in the namespace 'System.Net.Http' (are you missing an assembly reference?)

If you change the code to:

#r "System.Net.Http.Json.dll"
using System.Net.Http.Json;

It will work. This should be improved in the docs for #r in my opinion (and ideally there should be some sort of suggestion to import the corresponding system DLL like VS and Rider do).