User strings used by the program exceeds allowed limit by visual studio 2019

2.7k views Asked by At

I have been working with RazorGenerator.Mvc and RazorGenerator.MSBuild to precompile the views. The error i face when i try to build the project.

CS8103 C# Combined length of user strings used by the program exceeds allowed limit. Try to decrease use of string literals.

Visual Studio 2019 Version 16.3

When i remove RazorGenerator packages, clean and rebuild, the error is gone.

This github issue indicated that the fix will be in VS 2019. I tried everything to debug the issue but could not found it.

UPDATE

When i exclude some of views from the project and try rebuild, error gone. I think it might be the Visual Studio 2019 bug which they say is resolved but isn't.


Any work around that might work? I haven't yet registered view engine.

There might be fix regarding RazorGenerator tool if not for vs2019, if anyone can help or reference, i will be thankful.

Thanks for your time.

2

There are 2 answers

1
adnan On

I end up generating .cs for all my views manually. By setting property CustomTool for all views to RazorGenerator. That was it to work around for me.

0
Ehsan Waris On

Add this in your your-project-name.csproj file

<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> <RazorCompileOnBuild>false</RazorCompileOnBuild> <RazorCompileOnPublish>true</RazorCompileOnPublish> </PropertyGroup>