sharepoint - webpart is working on local server but not working on production when "SPSite" class is uesd in the webpart -


The webpart is working on the local server, but the production server is not working on the "SPS ite" class web part In uesd is The output throws this error on the server if I do not use that class in the webpage, then the web part works on the live machine.

Any reason that can cause an error?

The code in the webpage is:

Namespace Company News {[Grid ("40de3c60- 9e30-4050-b9f3-01e71868f522")] Public-class company news: System. Web. UI. WebControls Webpare WebPart {Personal HTML Text Writer Writer; Public Company News () {} Protected Override Zero Render Contents (HTMT Reader Writer) {Base. Reader Content (Author); (SPS ite site = SPContext.Current.Site) (SPWeb web = site. OpenWeb ()) {string listName = "News display"; Author.Write (listname); SPList list = null; Foreach (SPList list in the current web list.) {If (currentList.Title.Equals (list name, string com. InventoryCulture Ignore case)) {list = currentList; break; }} Author. Written bag ("ul"); ForeHatch (SPLIT item in list) {Author.light ("& lt; li style =" font-size: 12px; padding: 1px "& gt;"); Author. Type (item ["title"]. ToString () + "..."); Author. Type ("& lt; one class = \" small \ "href = \" # \ "& gt; read more & lt; / a & gt;"); Writer.Write ("& lt; / li>"); } Author. WrightEndTag ("UL"); }}}}}

The webpage is in the DLL bin folder and the web. The config file is an entry on the Web as a safe control. Other webpages that display the "Hero World" message, are also uploaded for production as well.

post-text "itemprop =" text ">

what I saw You should not wrap the objects from the current context in a used statement. The good article is here

Better practice will be to use the following:

  (SPSite mySite = new SPSite (SPContext.Current.Site.Url)) {...}  

In addition, you should see your solution on packaging in a WSP, from which to stsadm Apply it. Drag the GAC Not very good practice.

Sane


Comments