Pradeep H
Pradeep H

Reputation: 613

Exception when reading exception object stack trace - .Net Core API

I have an .NET core 3.1 API project which has reference to third party .NET dll (reference handled through windows compatibility pack).

Getting TypeLoadException inside the catch block (as shown in first screenshot)

The exception object has all details when viewed in debug mode including stack trace details. Getting below exception only when logger tries to read stack trace Information.

Able to see Stacktrace information when viewed through exception object, but get type error when drilled down to exception.Stacktrace

enter image description here

enter image description here

When I try to read stacktrace:

enter image description here

Upvotes: 0

Views: 580

Answers (1)

Wael Moughrbel
Wael Moughrbel

Reputation: 244

ToolboxDataAttribute from Namespace:System.Web.UI and Assembly: System.Web.dll is not compatible with .Net core according to the following official documentation: https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.toolboxdataattribute?view=netframework-4.8#applies-to

Try to find an alternative lib that gives same functionality as ToolboxDataAttribute and it is compatible with .Net core.

One work around for this is by moving your logic which uses ToolboxDataAttribute to the class library .NET Standard 2.0. Then you will be able to reference this class library from both .NET Core and .NET Framework projects.

Upvotes: 1

Related Questions