Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Different SharePoint web applications data using web.config

$
0
0

Hi Friends,

I am trying to get the List data from one web application site collection to another web application site collection using visual webpart. I posted my code and exception details.Can anyone help me on same.

 protected void Page_Load(object sender, EventArgs e)
        {
      
       
         try
            {

                SPSecurity.RunWithElevatedPrivileges(delegate()
                {

                    using (SPSite oSite = new SPSite(Convert.ToString(ConfigurationManager.AppSettings["WebUrl"])))
                    {
                        oSite.AllowUnsafeUpdates = true;
                        using (SPWeb oWeb = oSite.OpenWeb())
                        {
                            oWeb.AllowUnsafeUpdates = true;
                            SPList oList = oWeb.Lists.TryGetList(ConfigurationManager.AppSettings["WebLists"]);
                            if (oList != null)
                            {

                                SPListItemCollection items = oList.GetItems();
                                foreach (SPListItem item in items)
                                {

                                    string Title = Convert.ToString(item["Title"]);
                                    grdEmp.DataSource = Title;
                                    grdEmp.DataBind();
                                   
                                }

                            }

                            oSite.AllowUnsafeUpdates = false;
                            oWeb.AllowUnsafeUpdates = false;

                        }

                    }

                });
           
            }

            catch (Exception ex)
            {
                ex.ToString();
           
           
            }

        }

Web.config file below code I written:

<configuration>
<appSettings>
<add key="WebUrl" value="http://tiru-pc:4444/sites/AIBDevelopment" />
    <add key="WebLists" value="Tirupal" />
  </appSettings>
</configuration>

Error Message details:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace:


[COMException (0x80030102): Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))]
   Microsoft.SharePoint.Library.SPRequestInternalClass.GetWebListPermMask(String bstrUrl, String bstrListName) +0
   Microsoft.SharePoint.Library.SPRequest.GetWebListPermMask(String bstrUrl, String bstrListName) +134

[SPException: Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))]
   Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx) +27257906
   Microsoft.SharePoint.Library.SPRequest.GetWebListPermMask(String bstrUrl, String bstrListName) +225
   Microsoft.SharePoint.SPList.get_EffectiveBasePermissions() +102
   Microsoft.SharePoint.WebPartPages.WikiEditPage.OnPreRender(EventArgs e) +754
   System.Web.UI.Control.PreRenderRecursiveInternal() +108
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927
ee37bcb0-8ba9-4fbd-857a-059b7b5daf00
Y2:ee37bcb0-8ba9-4fbd-857a-059b7b5daf00


tirupal


Viewing all articles
Browse latest Browse all 25064

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>