Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 719671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:40:12+00:00 2026-05-14T05:40:12+00:00

After googling for many hours for a solution for the above Sharepoint exception, I

  • 0

After googling for many hours for a solution for the above Sharepoint exception, I have come to SO for help on this one…

I believe the cause of me getting the above exception is because of the following code:

try
{
    using (SPSite site = new SPSite(siteId, spUserToken))
    {
        using (SPWeb web = site.OpenWeb(webId))
        {
            createNewSite(web);
        }
    }
}

createNewSite(web) changes the name and URL of “web” using AllowUnsafeUpdates, so when it comes out of the method it has been changed. My few months worth of Sharepoint developing experience suggest that that is the cause of the exception. “web” is no longer used anymore so I can comfortably null it myself. The problem here is… it didnt work:

try
{
    using (SPSite site = new SPSite(siteId, spUserToken))
    {
        SPWeb web = null;
        using (web = site.OpenWeb(webId))
        {
            createNewSite(web);
            if (web != null)
            {
                web = null;
            }
        }
    }
}

I believe that the original developer used the using declaration to avoid SPWeb objects from leaking. Asides that I think it is okay for me to break this pattern solely for the purpose of getting rid of that dreaded exception.

So the question: what can I do to the above code to potentially fix this exception?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:40:12+00:00Added an answer on May 14, 2026 at 5:40 am

    Having a method called createNewSite that changes an existing site is a bad sign – you should post the code for that also.

    There is however no need to set web to null – it doesn’t have any effect as it is about to go out of scope anyway.

    A more likely cause is something wrong in the custom method you are calling or an issue with the validity of the ids used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a question, after allot of hours in googling and reading articles, i
After googling a bit I have found some tips about how to get online
After much googling I have been wondering what the benefits/differences are between mysql and
I did some googling to try to answer this question but even after that
I've seen variations of this by googling it but I have a windows form
After exhaustive googling and visiting many forums, I am yet to find a good
After reading this question , I was reminded of when I was taught Java
After lots of attempts and search I have never found a satisfactory way to
Is there any support for unit testing in Visual Studio 2005? After googling for
After reading the Head First Design Patterns book and using a number of other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.