How Do I Implement a Simple Example of Markdig In. Net 6 Razor Pages?

I am trying to do a really simple test of the Markdig library for .NET 6 (). I have added the package to my project and it shows up as expected in .csproj.

<PackageReference Include="Markdig" Version="0.28.0" />

I made a very simple Index page. The code is below.

using Markdig;

public class IndexModel : PageModel
{
    public IndexModel()
    {
    }

    public string Test { get; set; }

    public void OnGet()
    {
        var Test = Markdown.ToHtml("This is a text with some *emphasis*");
    }
}

However, I get the following error.

The type 'Markdown' exists in both 'Markdig.Signed, Version=0.22.0.0, Culture=neutral, PublicKeyToken=870da25a133885f8' and 'Markdig, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

I must be doing something wrong because I cannot find anyone else having this issue. Thanks for the help.

UPDATE: I tested a completely new razor pages project and I can get it working fine, but still having issues in adding it to my already existing project. I did some more digging and somehow Markdig.Signed.dll appears when I build the project. To get rid of it I tried

  • Adding and removing package Markdig.Signed.
  • Deleting bin and obj folders and doing dotnet build
  • doing dotnet clean and then dotnet build

But each time the Markdig.Signed.dll comes back.

FINAL UPDATE: I ended up just using Markdig.Signed instead of Markdig. This isn't really a solution, but will work just fine. I tried many different things to remove Markdig.Signed.dll from my computer, but it always came back when I built the project. I suspect it has do with the package/library being signed.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article