Sharepoint - Webpart Error that happens after IISRESET

Posted on 2010-01-11
Medium Priority
Last Modified: 2013-12-14
I kept getting this webpart error everytime I do an IISRESET. I've attached a screen shot.

A temporary fix I found is as follows:

1. Comment out all code from the webpart solution and only leave an empty CreateChildControls method there.
2. Build the solution and drop the dll into windows/assembly. Recycle AppPool.
3. Check to see that error is gone and webpart is empty.
4. Put the code back into the webpart solution
5. Build the solution and drop the dll into windows/assembly. Recycle AppPool
6. Check page to see that webpart is working properly.

After the fix, if I do an IISRESET, I get the webpart error again. If I do recycle then it'll be fine.
So, the webpart will work properly as long as I don't do IISRESETs.

What's going on?

Many thanks in advance, I've been stuck with this problem for months.
Question by:SOS_Helpdesk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 26284762


After placing your assembly to the GAC, you should add your webpart to the safe control list by adding a safe control entry for your custom assembly to the web.config file as follow:
<SafeControl Assembly="dll name", version=, Culture=neutral, PublicKeyToken=Replace it here form GAC" NameSpace="name space" TypeName="*" Safe="True" AllowRemoteDesigner="True"/>

After you have deployed your web part and registered it in the safe control , navigate to http://MyServer/_layouts/newdwp.aspx, where MyServer is the name of the server on which your sharepoint site is deployed.
Select the check boc next to MyNameSpace.MyClassName and then click PopulateGallery Button to add your web part in Gallery webpart.

for more information you can navigate to http://msdn.microsoft.com/en-us/library/ms415817.aspx

Author Comment

ID: 26285245
Thanks for both your replies. I've been to two out of the four sites you guys suggested and tried the solutions but it didn't work. The second solution sandipkharde suggested is how to add a webpart in general. The webpart I have is actually working, so the webpart is already in safe control and the webpart gallery.

The weird thing about my webpart is that it breaks AFTER an iisreset. Recycling the appPool doesn't break it. So I need to look into something deeper is what I think; what is iisreset doing that recycle isn't? Why does replacing the webpart with an empty one, then with one with code works?

To me, the situation looks like this...

1. After IISRESET, everything is forgotten, cache is cleared. Now when the webpart is loading for the first time, sharepoint finds an error, throws an exception, therefore I get the webpart error.

2. After I replace the webpart dll with an empty one and do a recycle on the appPool. Sharepoint approves the webpart (because it's empty, there is no error) so now the webpart works.

3. I replace the empty webpart with one that has code, but since sharepoint already approved this webpart, the webpart works.

4. Webpart continues to work until IISRESET is done again, clearing cache, etc.

I can't post my code for review so if this question is stuck, I would understand.

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

LVL 19

Expert Comment

ID: 26291541

I'm really trying to figure out what is going wrong here, but I just can't seem to see it either.
Recycling your app pool is the same as what IISRESET does, but then for all the w3wp worker processes. If you would place those dll's in the bin instead of the gac, when you would change your dll's IIS would automatically recycle your app pool to load those new dll's.

The only thing I don't really get about your error message: Is it the import of the webpart that won't work or the execution of it after an IISRESET?

Author Comment

ID: 26373381

It's the import of the webpart won't work after the iisreset. I need to apply the hack fix so import works, then apply the logic.

Thanks for your input. This looks like a deadend.

Accepted Solution

SOS_Helpdesk earned 0 total points
ID: 26499474
Turns out it wasn't SharePoint related - I was working with an external library, and something was being declared too early.  Problem solved, thanks for your help

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question