---
title: Loading custom classes from App_Code
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

By preparing custom classes that inherit from an appropriate base class, you can extend the functionality of Kentico. This approach allows you to implement the following types of objects:

- [Form controls](https://docs.kentico.com/k11/custom-development/developing-form-controls/managing-form-controls.md) and [inherited form control extenders](https://docs.kentico.com/k11/custom-development/developing-form-controls/inheriting-from-existing-form-controls.md)
- [Integration connectors](https://docs.kentico.com/k11/integrating-3rd-party-systems/using-the-integration-bus/creating-integration-connectors.md)
- [Marketing automation actions](https://docs.kentico.com/k11/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-marketing-automation/developing-custom-marketing-automation-actions.md)
- [Notification gateways](https://docs.kentico.com/k11/custom-development/miscellaneous-custom-development-tasks/notifications-api/developing-custom-notification-gateways.md)
- [Payment gateways](https://docs.kentico.com/k11/e-commerce-features/customizing-and-developing-your-store/payment-related-customizing/creating-a-custom-payment-gateway.md)
- [Scheduled tasks](https://docs.kentico.com/k11/custom-development/miscellaneous-custom-development-tasks/scheduling-custom-tasks.md)
- Custom [Smart search](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website.md) components:
  - [Search indexes](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/creating-custom-smart-search-indexes.md)
  - [Index analyzers](https://docs.kentico.com/k11/configuring-kentico/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes/creating-custom-smart-search-analyzers.md)
- [Translation services](https://docs.kentico.com/k11/custom-development/miscellaneous-custom-development-tasks/developing-custom-translation-services.md)
- [Workflow actions](https://docs.kentico.com/k11/managing-website-content/configuring-the-environment-for-content-editors/configuring-workflows/designing-advanced-workflows/creating-custom-action-workflow-steps.md)
- [UI extenders](https://docs.kentico.com/k11/custom-development/creating-custom-modules/creating-extenders-for-module-interface-pages.md)

> **Note:** **Note – Using code libraries**
>
> We strongly recommend using _**separate assemblies (Code library projects)**_ to store custom classes instead of the App\_Code folder. Custom code libraries provide the following advantages:
>
> - Cleaner separation of custom code from the default code of the Kentico web project.
> - Compilation performance – the code of a separate project is compiled into a DLL and does not require runtime compilation that slows down the web project.
> - Better accessibility of your custom classes from external applications or projects (for example projects running automated tests).
> - Easier re-usability across multiple projects.
>
> When using code libraries, you do NOT need to register custom classes as described in the section below.

## Registering custom classes in the App\_Code folder

If you decide to add custom classes into App\_Code, you need to register each class to allow the system to load it:

1. Edit your custom class.
2. Add a using statement for the **CMS** namespace.
3. Add the **RegisterCustomClass** assembly attribute above the class declaration (for every App\_Code class that you want to register).

```csharp

using CMS;

// Ensures that the system loads an instance of 'CustomClass' when the 'MyClassName' class name is requested.
[assembly: RegisterCustomClass("MyClassName", typeof(CustomClass))]

...

public class CustomClass
{
    ...
}

```

The **RegisterCustomClass** attribute accepts two parameters:

- The first parameter is a _string_ identifier representing the name of the class.
- The second parameter specifies the type of the class as a **System.Type** object. When the system requests a class whose name matches the first parameter, the attribute ensures that an instance of the given class is provided.

Once you have registered your custom classes, you can use them as the source for objects in the system. When assigning App\_Code classes to objects in the administration interface, fill in the following values:

- **Assembly name**: (custom\_classes)
- **Class**: must match the value specified in the first parameter of the corresponding _RegisterCustomClass_ attribute

![Assigning a custom App\_Code class to a new translation service](https://docs.kentico.com/docsassets/k11/loading-custom-classes-from-app_code/Assigning_App_Code_Class.png "Assigning a custom App_Code class to a new translation service")
