C# Design time licensing for pure C# Library

Keerthana Kolandasamy 1 Reputation point
2021-02-03T02:53:14.71+00:00

I have a library that has a base class, which can be build into a dll and distributed.

I want to implement licensing for the same - design time or compile time. The users can reference the dll and inherit the base class. But only if they have valid license their code should build, else should be notified of the absent license

Is there a way to establish licensing for this during design time or compile time? If the license is invalid, it should not build. Any help appreciated.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,124 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,631 Reputation points
    2021-02-04T01:34:53.83+00:00

    Hi KeerthanaKolandasamy-6556,
    The Microsoft .NET Framework defines a licensing model that allows developers to prevent the use of their classes unless a valid license can be granted. This licensing model is particularly well suited to redistributable components, which are typically sold to developers and subsequently redistributed as a part of the licensed developer's application. Noncomponent classes can easily take advantage of the infrastructure as well.
    Using the .NET licensing model, building a component that requires a valid license key to be present before it can be used is straightforward. You simply add a licensing-specific attribute to your class definition, and add a call to a license validation method from your class constructor.
    More details you can refer to this thread.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.