How to generate multiple DLL files by configuring the shared code in the app_code folder when developing an ASP. NET 2.0 web application

Source: Internet
Author: User

I recently worked on a secondary development of an ASP. NET 2.0 project.CodeAfter compilation, an error is reported: The system has imported the same simple name "app_code, version = 0.0.0.0, culture = neutral, publickeytoken = NULL"ProgramSet. Try to remove one of the references or add a signature to the reference to enable parallel mode. It turns out that the app_code.dll has been compiled in the original project and referenced in the secondary development project. Therefore, the name conflict occurs during compilation. Try to directly put the app_code folder for secondary development in the folder of the Virtual Site. When you run the pre-compilation for the first time, the following error occurs: The application has been pre-compiled, therefore, the directory "/website/app_code/" is not allowed /". It seems that you can only find a way to compile the shared code of secondary development into a DLL with other names.
Check it. NET 2005 documentation, found that the app_code folder can contain any number of files and subfolders, can still compile all the code into a single assembly, that is, app_code.dll, it seems that the DLL named after the folder name cannot be generated by the folder name. However, app_code has a feature that can be used in many ways.Programming LanguageWrite a custom class.Source codeTo compile the code into a single assembly, the code written in different languages must be placed in different subfolders, that is, the code in the same folder must be written in the same language, by configuring the web application, you can use the subfolders of the app_code folder as independent compilation units. Therefore, the generated dll must be a DLL independent of the programming language.
Create a code2nd sub-folder under the app_code folder of the project, move the shared code for secondary development to the sub-folder, and configure it in Web. config according to the sample code in the help document:

1 < Compilation debug = " False " >
2 < Codesubdirectories >
3 < Add directoryname = " Code2nd "   />
4 </ Codesubdirectories >
5 </ Compilation >

The website is successfully generated. Go to the bin folder of the generated website directory and browse it. With a new DLL, the file name is app_subcode_code2nd.dll, it is obviously the DLL ^_^ generated by the code in the code2nd sub-folder.
In another test, two more folders are created under the app_code folder, and two simple test codes are written. One is generated successfully using C # And the other VB, this method can be used to split large DLL files and update some code blocks by updating the shared code of Web applications.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.