Quickpart is a masterpiece of our famous kaneboy. It is an outstanding representative of the user control package and an important tool for Visual Web component development. The general process of using quickpart is: 1) create a web project, create a user control, compile and release the website, and obtain the required ascx and DLL files; 2) Deploy quickpart and activate quickpart feature on the website; 3) make the trust level of the Web application ready to use web components; 4) Copy ascx to the wpresources folder of the Web application and copy the DLL to the corresponding bin directory; 5) add quickpart on the website, edit attributes, and select the corresponding ascx file; 6) Now you can use the encapsulated user control. I want to make quick part easier.If we want to automatically deploy the developed user control and DLL, and then drag a quickpart containing the user's empty control on the website, what should we do if quickpart is used when a Web part is added? First, we need to understand the relationship between the DLL of the Web part and the. webpart file: The same quickpart. dll can be described as different Web parts using different. webpart description files. In. specify wrappedusercontrolpath in the webpart file to set the user control to be loaded by default. set a meaningful title in the webpart file to make the same quickpart. dll will display multiple more meaningful available Web parts on your Web Part selection page. Using the. webpart file, we solved the trouble of adding quickpart on the website and selecting which user control to load. We have not solved the problem of automatically copying ascx files and DLL files to the corresponding directory. The Assembly element in solution has a sub-element named classresources, which is used to deploy Assembly resources. Therefore, we can use the ascx file as the DLL resource so that WSP can help us complete this deployment, for example, we want to deploy iparkdebugpartuc. DLL is the assembly of the user control, and its corresponding resources will be in bin \ wpresources \Iparkdebugpartuc\ Path (note that the folder at the end of the path is the Assembly name). Therefore, we create the following folder structure under wspbuilder: Copy the DLL to the 80 \ bin directory, and copy the ascx file to 80 \ bin \ wpresources \Iparkdebugpartuc\ Path Using Solution assembly and classresource, we solve the problem of automatic copying and deployment of ascx and DLL. When wspbuilder generates a WSP file, the manifest file automatically adds codeaccess-related settings to the assembly, so you do not need to modify the trustlevel of the Web application. --------------------------------- Solution started ------------------------------ So our solution is: 1) First, create a wspbuilder project based on the "[best practice] How to Use wspbuilder in SharePoint Team development" to perform Web Part packaging, deployment, and debugging; create the required folder structure and add a wspbuilder blank feature, which is similar to the following: Note that the folders under wpresources must be the same as the DLL name of the user control you want to generate. 2) create a web application project and create one in the project. in the webpart file, note that the metadata type is used to indicate the corresponding DLL. Here, of course, it is the package type in our quickpart. <? XML version = "1.0" encoding = "UTF-8"?> <Webparts> <Webpart xmlns = "http://schemas.microsoft.com/WebPart/v3"> <Metadata> <! -- The following GUID is used as a reference to the Web Part class, And it will be automatically replaced with actual type name at deployment time. --> <Type name = "Microsoft. PRC. Sharepoint. consumerquickpart, quickpart, version = 1.0.0.0, culture = neutral, publickeytoken = 2d0bb71b2dd16f9e"/> <Importerrormessage> cannot import Web part. </importerrormessage> </Metadata> <DATA> <Properties> <Property name = "title" type = "string"> ipark debug demo Web Part </property> <Property name = "Description" type = "string"> ipark debug demo description </property> <Property name = "wrappedusercontrolpath" type = "string"> ~ \ Wpresources \ iparkdebugpartuc. ascx </property> </Properties> </Data> </Webpart> </Webparts> In this way, the Web application project is like: Set the iparkdebugpartuc. ascx and iparkdebugpart. webpart files to copy always: Add the post-build command to Build Events in the project properties: Copy "$ (targetdir) iparkdebugpartuc. dll" $ (solutiondir) iparksolution \ 80 \ bin \"; Copy "$ (targetdir) iparkdebugpartuc. ascx" $ (solutiondir) iparksolution \ 80 \ wpresources \ iparkdebugpartuc \"; Copy "$ (targetdir) iparkdebugpart. webpart" $ (solutiondir) iparksolution \ 12 \ template \ Features \ iparkdebugpartfeature \"; 3) modify elements. xml of iparkdebugpartfeature in the wspbuilder project and add <Module name = "webparts" list = "113" url = "_ catalogs/WP"> <File Path = "iparkdebugpart. webpart" url = "iparkdebugpart. webpart" type = "ghostableinlibrary"/> </Module> 4) Well, your solution looks like: First, build the iparkdebugpartuc project, right-click "iparksolution", and click "build WSP" to generate the WSP file, right-click the menu and you will see that both deploy and upgrade are available. Then you can deploy the solution. Go to your website set and activate iparkdebugpartfeature. Then you can find this Web Part in the Web part list of the website: You can right-click "attach to IIS worker processes" in the wspbuilder menu of your web application project to start debugging your user control. When you refresh the page where the user control is located, your Visual Studio will start debugging: --------------------------------- The solution has ended ------------------------------ Supplement: To use this method, you do not need to deploy quickpart in advance. All you need to do is copy quickpart. DLL to the 80 \ bin directory of wspbuilder. The WSP package will automatically deploy it: |