'using AventStack.ExtentReports gives an error

In a YouTube Demo I was given this code and I get this error which has me stumped - 'ExtentReports' does not contain a constructor that takes 2 arguments. is my reference wrong? I am using version 3.03 of ExtentReports

using NUnit.Framework;
using AventStack.ExtentReports;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    namespace ExtentDemoYoutube
    {
        [TestFixture]
        public class BasicReport
        {
            public ExtentReports extent;
            public ExtentTest test;

            [OneTimeSetUp]
            public void StartReport()
            {
                string pth = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
                string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
            string projectPath = new Uri(actualPath).LocalPath;

            string reportPath = projectPath + "Reports\\MyOwnReport.html";

            extent = new ExtentReports(reportPath, true);

            extent.AddSystemInfo("Host Name", "Joe Loyzaga")
                .AddSystemInfo("Environment", "QA")
                .AddSystemInfo("User Name", "Joe Loyzaga");

            extent.LoadConfig(projectPath + "extent-config.xml");

        }

        [Test]
        public void DemoReportPass()
        {
            test = extent.StartTest("DemoReportPass");
            Assert.IsTrue(true);
            test.log(LogStatus.Pass, "Assert Pass as condition is True");
        }

        [Test]
        public void DemoReportFail()
        {
            test = extent.StartTest("DemoReportFail");
            Assert.IsTrue(false);
            test.log(LogStatus.Pass, "Assert Pass as condition is Fail");

        }

        [TearDown]
        public void GetResult()
        {
            var status = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>" +TestContext.CurrentContext.Result.StackTrace+"</pre>";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            if(status==NUnit.Framework.Interfaces.TestStatus.Failed)

            {
                test.Log(LogStatus.Fail, stackTrace + errorMessage);
            }
            extent.EndTest(test);
        }

        [OneTimeTearDown]
        public void EndReport()
        {
            extent.Flush();
            extent.Close();
        }


    }
}


Solution 1:[1]

This is a sample extentreport using selenium that produces a report that uses selenium webdriver

using AventStack.ExtentReports;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Configuration;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;

namespace FrameworkForJoe
{
    [TestFixture]
    public class SampleTest
    {
        private static IWebDriver driver;
        private static ExtentReports extent;
        private static ExtentHtmlReporter htmlReporter;
        private static ExtentTest test;

        [OneTimeSetUp]
        public void SetupReporting()
        {
            htmlReporter = new ExtentHtmlReporter(@"C:\Git\joesreport.html");

            htmlReporter.Configuration().Theme = Theme.Dark;

            htmlReporter.Configuration().DocumentTitle = "JoesDocument";

            htmlReporter.Configuration().ReportName = "JoesReport";

            /*htmlReporter.Configuration().JS = "$('.brand-logo').text('test image').prepend('<img src=@"file:///D:\Users\jloyzaga\Documents\FrameworkForJoe\FrameworkForJoe\Capgemini_logo_high_res-smaller-2.jpg"> ')";*/
            htmlReporter.Configuration().JS = "$('.brand-logo').text('').append('<img src=D:\\Users\\jloyzaga\\Documents\\FrameworkForJoe\\FrameworkForJoe\\Capgemini_logo_high_res-smaller-2.jpg>')";
            extent = new ExtentReports();

            extent.AttachReporter(htmlReporter);
        }

        [SetUp]
        public void InitBrowser()
        {
            driver = new ChromeDriver();
            driver.Manage().Window.Maximize();            
        }

        [Test]
        public void PassingTest()
        {
            test = extent.CreateTest("Passing test");

            driver.Navigate().GoToUrl("http://www.google.com");

            try {
                Assert.IsTrue(true);
                test.Pass("Assertion passed");
            } catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [Test]
        public void FailingTest()
        {
            test = extent.CreateTest("Failing test");

            driver.Navigate().GoToUrl("http://www.yahoo.com");

            try
            {
                Assert.IsTrue(false);
                test.Pass("Assertion passed");
            }
            catch (AssertionException)
            {
                test.Fail("Assertion failed");
                throw;
            }
        }

        [TearDown]
        public void CloseBrowser()
        {
            driver.Quit();
        }

        [OneTimeTearDown]
        public void GenerateReport()
        {
            extent.Flush();
        }
    }
}

Solution 2:[2]

Use import stament as follows

    using RelevantCodes.ExtentReports;

Solution 3:[3]

#create 2 files#
1) ExtentManager.cs n write following code
    using AventStack.ExtentReports;
    using AventStack.ExtentReports.Reporter;
    using AventStack.ExtentReports.Reporter.Configuration
namespace ProTradeExeAutomation
{
     public class ExtentManager
        {
                public static ExtentHtmlReporter htmlReporter;
                private static ExtentReports extent;

                private ExtentManager()
                {

                }
                public static ExtentReports GetInstance()
                {
                    if (extent == null)
                    {


    string startupPath = System.IO.Directory.GetCurrentDirectory();
                    string startupPathSubString = startupPath.Substring(0, 49);
                    string fullProjectPath = new Uri(startupPathSubString).LocalPath;
                    string reportpath = fullProjectPath + "Reports\\SampleReport.html";

                    htmlReporter = new ExtentHtmlReporter(reportpath);
                    htmlReporter.Configuration().Theme = Theme.Dark;

                    extent = new ExtentReports();
                    extent.AttachReporter(htmlReporter);
                    extent.AddSystemInfo("Host Name", "ABC");
                    extent.AddSystemInfo("Environment", "Test QA");
                    extent.AddSystemInfo("Username", "XYZ");
                    htmlReporter.LoadConfig("urpath\\extent-config.xml"); //Get the config.xml file 
                }
                return extent;
            }
    }
}
##In Test File create obj of ExtentManager n use to create test##

 public class LoginPageTest
    {
        LoginPage loginPage;
        ExtentReports rep = ExtentManager.GetInstance();
        ExtentTest test;

        [Test,Order(1)]
        public void LoginPageTestMethod()
        {
            test = rep.CreateTest("LoginPageTest");
            test.Log(Status.Info, "Starting test");
            loginPage.LogginPage(Constant.USERNAME, Constant.PASSWORD);
            Thread.Sleep(9000);
            Thread.Sleep(5000);
            try
            {
                Assert.IsTrue(true);
                test.Pass("Test passed");
            }
            catch (AssertionException)
            {
                test.Fail("Test failed");
            }
            rep.Flush();//remember to do this
    }

Solution 4:[4]

Answer to the question above: Use RelevantCodes.ExtentReports. Go to Manage Nuget Packages->Browse for ExtentReports. Before downloading select version 2.41.0 and then install. 2.41.0 has support for RelevantCodes.ExtentReport while version 4.0.3 has Aventstack.ExtentReports.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 joe loyzaga
Solution 2 Ashish Kamble
Solution 3 RisingDeveloper
Solution 4 Smitha