ExceptionLess on a Class Library project

683 Views Asked by At

How can I use ExceptionLess on a Visual Studio Class Library project without create a settings file?

In other words, the Class Library project creates a DLL with some methods inside it, but I want to report exceptions and notifications during call of these methods of the DLL with ExceptionLess.

Something like:

using System;
using System.Threading.Tasks;
using Exceptionless.Configuration;
...
...
namespace LibraryName
{
    public class Activities
    {
        public static string MethodOne(string var1, string var2)
        {
            ...
            try
            {
                ...code...
            }
            catch(Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }
        public static int MethodTwo(int var1, int var2)
        {
            ...
            try
            {
                ...code...
            }
            catch(Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }
     }
}

So, I should be able to "port" the LibraryName.dll and ExceptionLess DLLs.

1

There are 1 best solutions below

1
On BEST ANSWER

Done!

How?

  1. Installing nuGet package ExceptionLess (last stable version) to Class Library project.
  2. Adding directive Exceptionless (using ExceptionLess;)
  3. Setting the api key directly on the default instance (ExceptionlessClient.Default.Configuration.ApiKey = "3BC1Ntsdjhf*********JGytyuiiud7";)

and submitting logs and exceptions from code.

Thanks.