Answered by:
Error occurred in deployment step 'Activate Features': The type initializer for ' 'threw an exception

Question
-
Hi,
I have develeoped custom timer job using vs 2010 to deploy in sharepoint server.
While I right click on solution explorer and click on deploy then system throws an error "Error occurred in deployment step 'Activate Features': The type initializer for 'TestTimerJob.TestTimerJob' threw an exception."
Please suggest.
Thanks.
Knowledge is power.
Friday, November 16, 2012 11:58 AM
Answers
-
Hi Manoj,
The error is due to how visual studio deploy the wsp file.
Case1 : By default when you add a feature in your project, the attribute Active On Deafult is set to True. Basically we should not set this attribute until and unless its required. So set it true only if required. Second thing is when you are deploying your solution by right clicking on solution and select Deploy, visual studio will try to activate all features which are there in the solution. So if you really need to deploy your solution using visula studio, just click on project properties->select sharepoint and select No Activation under Active deployment configuration. It will deploy your solution and you can manually actiavte your feature from UI,stsadm or powershell
Case 2: Organize you package.package file properly. All independant features must be on top folloyed by any dependant feature. For example if you have some site columns, and these columns is used in a list definition, site columns feature must be activate 1st then the list definition fetaure.
Case 3: After checking above two steps, share your code for feature receiver. (At what scope your feature is running).
Note : for debugging use debugger.launch() at the start of feature activation.
- Proposed as answer by Jinchun ChenMicrosoft employee Friday, November 23, 2012 2:37 AM
- Marked as answer by Jinchun ChenMicrosoft employee Thursday, November 29, 2012 2:00 AM
Wednesday, November 21, 2012 8:51 AM
All replies
-
Debugger is not firing at all. SO not able t do debugging.
Knowledge is power.
Friday, November 16, 2012 12:34 PM -
It is difficult to debug the code that is executed during activation but you could catch the exception and write the text of the exception to a file in the EventReceiver to find out what the exception is.Friday, November 16, 2012 2:59 PM
-
Look in your SPLog file (default: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS) and see if the full exception is in there. If you find it, post it here.Friday, November 16, 2012 6:45 PM
-
Debugger is not firing at all. SO not able t do debugging.
Knowledge is power.
Have you tried to set break point on feature activate? If not then set break point on feature activate and try to debug your code line by line.
See this mSDN article to debug timer job:
http://msdn.microsoft.com/en-us/library/ff798310.aspx
http://www.codeproject.com/Articles/70866/Debugging-Custom-SharePoint-Timer-Jobs
Also make sure that:
1. Once you deploy the time job, you need to reset the IIS
2. restart the window timer service from services.msc
Let us know your result
Hemendra: "Yesterday is just a memory,Tomorrow we may never see"
Whenever you see a reply and if you think is helpful, click "
Vote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "
Mark As Answer
- Proposed as answer by Jinchun ChenMicrosoft employee Friday, November 23, 2012 2:37 AM
Monday, November 19, 2012 12:15 PM -
Please follow the steps given in below link to debug the job
http://msdn.microsoft.com/en-us/library/ff798310.aspx
and suppose you are not able to debug the code , then retart the timer job forcefully, then debug , debug point would definately come.
Please mark answer , if you thisnk answer is correct.
Wednesday, November 21, 2012 5:24 AM -
Hi Manoj,
The error is due to how visual studio deploy the wsp file.
Case1 : By default when you add a feature in your project, the attribute Active On Deafult is set to True. Basically we should not set this attribute until and unless its required. So set it true only if required. Second thing is when you are deploying your solution by right clicking on solution and select Deploy, visual studio will try to activate all features which are there in the solution. So if you really need to deploy your solution using visula studio, just click on project properties->select sharepoint and select No Activation under Active deployment configuration. It will deploy your solution and you can manually actiavte your feature from UI,stsadm or powershell
Case 2: Organize you package.package file properly. All independant features must be on top folloyed by any dependant feature. For example if you have some site columns, and these columns is used in a list definition, site columns feature must be activate 1st then the list definition fetaure.
Case 3: After checking above two steps, share your code for feature receiver. (At what scope your feature is running).
Note : for debugging use debugger.launch() at the start of feature activation.
- Proposed as answer by Jinchun ChenMicrosoft employee Friday, November 23, 2012 2:37 AM
- Marked as answer by Jinchun ChenMicrosoft employee Thursday, November 29, 2012 2:00 AM
Wednesday, November 21, 2012 8:51 AM -
your information is really helpful for deploying Sharepoint Timer job...
Thanks
Monday, August 4, 2014 7:40 PM -
try System.Diagnostics.Debugger.Launch();Wednesday, June 8, 2016 2:39 PM