'Put an asp.net user controls into a reusable dll

I want to put some ASP.NET user controls, which we use in different projects, into a single dll so we can use them in every project with the same code base. I think I tried all possible ways I found on google, but when I add the generated dll in another project, Visual Studio can't find my controls from an aspx page. I wrote the register tag <Register Assembly="MyAssembly" Namespace="MyNamespace" TagPrefix="myPref".

When I start typing <myPref: IntelliSense doesn't give me any suggestions and if I start debugging anyway, Visual Studio can't find that tag at runtime.

Most of the documentations I read, are based on this (from 2011) and I followed the code guidelines:

https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/aa479318(v=msdn.10)?redirectedfrom=MSDN

Another one, which uses a different way is this:

https://odetocode.com/blogs/scott/archive/2005/10/06/using-msbuild-and-ilmerge-to-package-user-controls-for-reuse.aspx

Here, I got the following error message:

The TargetPath parameter must be specified if the target directory needs to be overwritten.

I was able to fix this by specifying an absolute path instead of $(TempPath) in the .csproj file. After that, i got the next error: Visual Studio can't find the class types of my controls and pages.

In Visual Studio (2022), I tried every combination of checkboxes in the publish configuration dialog, but nothing worked.

I hope someone did this with current versions of Visual Studio and can help me.

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source