0

I'm trying to output some HTML in a polyglot notebook using RazorInteractive.

Here's the cell contents currently:

#!razor

<h1>Hi</h1>

This errors with:

Error: System.ArgumentException: An item with the same key has already been added. Key: img
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at RazorInteractive.ModelCreator.<>c.<GetVariables>b__1_0(IDictionary`2 dictionary, ScriptVariable variable)
at System.Linq.ImmutableArrayExtensions.Aggregate[TAccumulate,T](ImmutableArray`1 immutableArray, TAccumulate seed, Func`3 func)
at RazorInteractive.ModelCreator.GetVariables(CSharpKernel csharpKernel)
at RazorInteractive.ModelCreator.CreateModelFromCurrentVariables(Kernel kernel)
at RazorInteractive.ModelCreator.<>c.<CreateModelFromCurrentVariables>b__0_0(Kernel x)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at RazorInteractive.ModelCreator.CreateModelFromCurrentVariables(Kernel kernel)
at RazorInteractive.RazorExtensions.<>c__DisplayClass1_0`1.<UseRazor>b__0(RazorMarkdown markdown, TextWriter writer)
at Microsoft.DotNet.Interactive.Formatting.Formatter.<>c__DisplayClass48_0`1.<Register>b__0(Object value, FormatContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter.cs:line 497
at Microsoft.DotNet.Interactive.Formatting.Formatter`1.FormatTo(T obj, FormatContext context, String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter{T}.cs:line 86
at Microsoft.DotNet.Interactive.Formatting.Formatter.ToDisplayString(Object obj, String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive.Formatting\Formatter.cs:line 269
at Microsoft.DotNet.Interactive.FormattedValue.<>c__DisplayClass8_0.<CreateManyFromObject>b__0(String mimeType) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\FormattedValue.cs:line 47
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at Microsoft.DotNet.Interactive.KernelInvocationContextExtensions.Display(KernelInvocationContext context, Object value, String[] mimeTypes) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelInvocationContextExtensions.cs:line 22
at RazorInteractive.RazorKernel.HandleAsync(SubmitCode command, KernelInvocationContext context)
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 325
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 51

What's going wrong?

Ian Newson
  • 7,679
  • 2
  • 47
  • 80

0 Answers0