Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 806221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:12:37+00:00 2026-05-15T00:12:37+00:00

I’m interested to find out whether there are any standards or resources that you

  • 0

I’m interested to find out whether there are any standards or resources that you can recommend for developing license models in C#?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:12:38+00:00Added an answer on May 15, 2026 at 12:12 am

    In C# you can use the Licensing class supplied by Microsoft. A sample is available through the link.

    Basically you create a class that inherits from LicenseProvider and type the

    [LicenseProvider(typeof(MyControlLicenseProvider))]
    

    as an attribute to your class that you would like to have licensed. In your implementation (MyControlLicenseProvider) you can code the appropriate methods for validating the license to your needs and then have your code call

    License license = LicenseManager.Validate(typeof(MyControl), this);
    

    If license is not null your application/control is licensed.

    As Sir Graystar states, no system is fool-proof, and someone with the needed skills could engineer themselves around your validation. Don’t spend too many hours implementing a rock hard system, but don’t make it to easy to circumvent either. 🙂

    Using a hash like SHA or one of the MD hash functions and feed them some key data could be used to create a simple validation check. Your validation method could do something in the likes of

    public override License GetLicense(LicenseContext context,
                                       Type type,
                                       object instance,
                                       bool allowExceptions)
        if (context.UsageMode == LicenseUsageMode.Designtime) {
            // Creating a special DesigntimeLicense will able you to design your
            // control without breaking Visual Studio in the process
            return new DesigntimeLicense();
        }
        byte[] existingSerialKey = getExistingSerial();
        // Algorithm can be SHA1CryptoServiceProvider for instance
        byte[] data = HashAlgorithm.Create().ComputeHash(
            username,
            dateRequested,
            validUntilDate,
            // any other data you would like to validate
        );
        // todo: also check if licensing period is over here. ;-)
        for (int l = 0; l < existingSerialKey.Length; ++l) {
            if (existingSerialKey[i] != data[i]) {
                if (allowExceptions){
                    throw new LicenseException(type, instance, "License is invalid");
                }
                return null;
            }
        }
        // RuntimeLicense can be anything inheriting from License
        return new RuntimeLicense();
    }
    

    This method returns a custom License, one that for instance has properties regarding the licensing, like a DateTime for the time when licensing runs out. Setting this up should not take to long, it works well with both WinForms and on ASP.NET sites, and will thwart (with no guarantee implied) a simple attempt to break your licensing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of other questions out there that deal with this
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm interested in microtypography issues on the web. I want a tool to fix:
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.