Studies show that good grammar leads to more promotions and higher salaries. Write with Grammarly

C# Error CS7013 – Name exceeds the maximum length allowed in metadata

C# Compiler Error Message

Error CS7013 – Name exceeds the maximum length allowed in metadata

Reason for the Error

You will usually receive the C# compiler error CS7013 Name exceeds the maximum length allowed in metadata error when you have an identifier is 1023 or more characters in length including its qualified name that is not allowed in the metadata of the .NET assembly.

Below is a sample code snippet that generates the error code CS7013 in C#

// The following namespace name has 514 characters.
namespace tttttZ6prejlojREIEu9juDzgtaAms16VoxweD79tdJWq9Cj1NR9fd32XwfgnlKa5H4C1sL0V4LDMJXwle3tijEFYDLYi1A1sPCKcXyzE36wDsUTQpnuFyl7CmwbLv5FfPwA0Teyuq7ai33zR9tImc59pJ6uLGlmU4cNjvCE0mJhHVSsYqdX8YiE2LOHALeIXzcBs1FCT41yzPsROe7xUm93Gjvw5Yt0vXDdprbETZq4fLRUJvNNbirch1kEj3RinD83hbMy9zDdj5n8WuWoYtDaJaLu82VNM1r09RLwZjDyH8mwZ9gAbe9pW5FdjM7um8F6Zwlm8J3K7h8qSPvBi8XNit9R352Z9FAB5vV3sqkf5SvDgDwTLVE45RzyCVzB8yOxsuGvpGnX43p5KVSrDicyK5QJ9uThDak0QUOGkVtqQBSIPpxjb5YBuQ8K7kYklGPJcexRLtHLPeXgKd2LDrI3Y6MCnbKPd2Gv8tHM6ZUO9vnHF3ZDTOdM3fSKMo4xPQ
{
    // The class has 510 characters.
    public class tZ6prejlojREIEu9juDzgtaAms16VoxweD79tdJWq9Cj1NR9fd32XwfgnlKa5H4C1sL0V4LDMJXwle3tijEFYDLYi1A1sPCKcXyzE36wDsUTQpnuFyl7CmwbLv5FfPwA0Teyuq7ai33zR9tImc59pJ6uLGlmU4cNjvCE0mJhHVSsYqdX8YiE2LOHALeIXzcBs1FCT41yzPsROe7xUm93Gjvw5Yt0vXDdprbETZq4fLRUJvNNbirch1kEj3RinD83hbMy9zDdj5n8WuWoYtDaJaLu82VNM1r09RLwZjDyH8mwZ9gAbe9pW5FdjM7um8F6Zwlm8J3K7h8qSPvBi8XNit9R352Z9FAB5vV3sqkf5SvDgDwTLVE45RzyCVzB8yOxsuGvpGnX43p5KVSrDicyK5QJ9uThDak0QUOGkVtqQBSIPpxjb5YBuQ8K7kYklGPJcexRLtHLPeXgKd2LDrI3Y6MCnbKPd2Gv8tHM6ZUO9vnHF3ZDTOdM3fSKMo4xPQ
    {
        public static void Main()
        {
        }
    }

}

You receive the below error when running this.

1>C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs(5,18,5,528): error CS7013: Name ‘ttttZ6prejlojREIEu9juDzgtaAms16VoxweD79tdJWq9Cj1NR9fd32XwfgnlKa5H4C1sL0V4LDMJXwle3tijEFYDLYi1A1sPCKcXyzE36wDsUTQpnuFyl7CmwbLv5FfPwA0Teyuq7ai33zR9tImc59pJ6uLGlmU4cNjvCE0mJhHVSsYqdX8YiE2LOHALeIXzcBs1FCT41yzPsROe7xUm93Gjvw5Yt0vXDdprbETZq4fLRUJvNNbirch1kEj3RinD83hbMy9zDdj5n8WuWoYtDaJaLu82VNM1r09RLwZjDyH8mwZ9gAbe9pW5FdjM7um8F6Zwlm8J3K7h8qSPvBi8XNit9R352Z9FAB5vV3sqkf5SvDgDwTLVE45RzyCVzB8yOxsuGvpGnX43p5KVSrDicyK5QJ9uThDak0QUOGkVtqQBSIPpxjb5YBuQ8K7kYklGPJcexRLtHLPeXgKd2LDrI3Y6MCnbKPd2Gv8tHM6ZUO9vnHF3ZDTOdM3fSKMo4xPQ.tZ6prejlojREIEu9juDzgtaAms16VoxweD79tdJWq9Cj1NR9fd32XwfgnlKa5H4C1sL0V4LDMJXwle3tijEFYDLYi1A1sPCKcXyzE36wDsUTQpnuFyl7CmwbLv5FfPwA0Teyuq7ai33zR9tImc59pJ6uLGlmU4cNjvCE0mJhHVSsYqdX8YiE2LOHALeIXzcBs1FCT41yzPsROe7xUm93Gjvw5Yt0vXDdprbETZq4fLRUJvNNbirch1kEj3RinD83hbMy9zDdj5n8WuWoYtDaJaLu82VNM1r09RLwZjDyH8mwZ9gAbe9pW5FdjM7um8F6Zwlm8J3K7h8qSPvBi8XNit9R352Z9FAB5vV3sqkf5SvDgDwTLVE45RzyCVzB8yOxsuGvpGnX43p5KVSrDicyK5QJ9uThDak0QUOGkVtqQBSIPpxjb5YBuQ8K7kYklGPJcexRLtHLPeXgKd2LDrI3Y6MCnbKPd2Gv8tHM6ZUO9vnHF3ZDTOdM3fSKMo4xPQ’ exceeds the maximum length allowed in metadata.

Solution

To fix the C# compiler error CS7013, ensure that your identifier along with the qualified name is always less than 1024 characters.

In the above example, just remove/ reduce one character form namespace or from class name.