Search code examples
asp.netdlluser-controlsascxilmerge

Multiple controls in a DLL using Visual Studio


I have a series of custom user controls (ASCX files) which have been tested and are confirmed to be in working order. Using the method provided by Microsoft (https://msdn.microsoft.com/en-us/library/aa479318.aspx) I have successfully managed to create a DLL for each control and reuse them in several different applications.

What I would like to do now is to combine the controls into a single DLL, as importing 5 or so DLL's in each application can be a bit of a hassle, but this is where things tend to get interesting. When I combine the controls by using ILMerge I get results included but not limited to the following:

  • Controls failing to render entirely
  • Controls corrupting their Javascript so it shows as raw HTML

Therefore my question is whether it is indeed possible to combine several custom controls into a solitary DLL and if so how? All of my controls are in a single solution and contain both Javascript code and server-side code. Moving the Javascript to a separate JS file would not be a problem but then I would like to know whether it is possible to include the Javascript into the JS file as well.

Any advice is appreciated!


Solution

  • One project with N user controls (.ascx), with inline javascript, etc, no worries. And of course, any other C# classes within the project will also be merged into the same dll (that script is almost what you need, it should put the output dll over the default, so you can use "project references"...): User Controls (asp.net, ascx-files) inside a C# class library, build error (aspnet_compiler.exe)

    I'll see if I can dig up an example project, been a while...

    PS: no sample project available, although; if you need it, I could quickly create one.