Two ways to deploy webpart

Source: Internet
Author: User

 The subject content is referenced from:Http://www.cnblogs.com/chenchaospr/archive/2008/04/29/1176631.html, Slightly adjusted

  Step 1: deploy the DLL file of the webpart.

The first deployment method is to deploy it to the bin directory. The webpart deployed in this mode can only be used by the current virtual server;

Step: copy the DLL file: Open the root directory of the virtual server, such as c: \ Inetpub \ www, and create a new bin directory. Unlike sharepoint2003, the bin directory does not exist by default. Then copy the DLL to the bin.

The second method is to deploy the webpart to the GAC, so that the deployed webpart can be used in all virtual servers and has high efficiency.

Step: drag the DLL file directly to the path "C: \ WINDOWS \ assembly" and it will be automatically registered to GAC.

 

  Step 2: modify web. config

Register a webpart as a security control. For example: <safecontrol Assembly = "webpart1, version = 1.0.0.0, culture = neutral, publickeytoken = 7a4e03cbe00b6e98" namespace = "webpart1" typename = "webpart1" Safe = "true"/>

 

  Step 3: There are two methods,

First, create a description file and automatically import the webpart.

There is a lot of knowledge about the creation of the description file. In sharepoint2007, there are two types of webpart description files, one extension is. webpart. The extension is. DWP ,. the usage of DWP is the same as that of DWP of sharepoint2003 .. DWP appears mainly to be compatible with the previous version. We recommend that you use the. webpart description file.

You can put the description file in two places (in fact, there should be a third place to put, not to mention). The first place is webpart Gallery, the second part is the wpcatalog directory under the root directory of the virtual server .. The usage of DWP and. webpart files is the same.

When adding wpcatalog, You need to restart the application (modify web. config to restart the application ). After the application is restarted, sharepoint2007 reads the files in wpcatalog and loads them to the memory for selection. Now the webpart is deployed. The biggest problem with this method is that you have to write the description file by yourself, instead of automatically generating it (the wspbuilder tool will automatically generate it ).

The second method is placed in webpart Gallery.,

This is a built-in documentation library of sharepoint2007. The advantage here is that you do not need to restart the application. When you add the description file here, you can see the newly added webpart directly in the list of added webparts. In addition to manually uploading the. DWP or. webpart description file to the webpart gallery, it can also be automatically generated. Automatic Generation depends on two conditions. The first is that your dll has been copied to the correct position, and the second is that the description has been added to Web. config, which is indispensable. When the two conditions are met, select the new button on the webpart gallery to list the newly deployed webpart. The position of webpart gallery is in the Action menu of the home page. Select site settings-> modify all settings, and then select webpart To Go To The webpart gallary.

Click the populate gallery button to add the automatically generated description file to the webpart Gallery.

Note that if your DLL is a webpart of sharepoint2003 (that is, the assembly of. net1.1), The. DWP description file is automatically generated. If you are an assembly of. net2.0, that is, the webpart of sharepoint2007, A. webpart description file will be generated.

Another problem is that a strongly signed assembly. If you want to deploy it in GAC, you only need to copy the DLL to GAC. The other steps are the same, the difference is the location where the DLL is stored. When you want to add it to GAC, you must sign the Assembly, that is, create a strong signature assembly. Use Sn-k outfile to generate the key. However, if you place a strongly signed assembly in the bin directory instead of the GAC, you may find such a dialog box:

This is because the Assembly is installed in a trusted area. How can this problem be solved? There are two methods: one is to use the DWP file description. When you use the DWP file description, this dialog box does not appear no matter whether the DWP file is in webpart gallery or wpcatalog, webpart can be used normally. The second is to declare the Assembly in assemblyinfo. add "[Assembly: system. security. allowpartiallytrustedcallers ()] ", and then use. there is no problem with the webpart description file. Whether this file is stored in webpart gallery or wpcatalog, this statement is only true. the webpart description file is valid. Here you will also find an interesting phenomenon. When you use a strong signature, whether it is automatically generated. the webpart file is directly uploaded to the webpart Gallery. it is strange that the publickeytoken in a webpart file is null. I didn't want to understand what was going on, but this does not affect the use of webpart.

In addition, when deployed in the GAC, The. webpart file cannot be automatically generated when it is new in the webpart gallery, so it must be handwritten. The sample you downloaded contains all the code and descriptions of. DWP and. webpart for your reference. The deployed webpart should look like this:

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.