SPWeb disposing himself and causing exception - sharepoint

When trying to use SPWeb.GetSiteData(SPSiteDataQuery) (Trying to bind some data to SPGridView), it throws me an TargetInvocationException with a following stacktrace:
Exception
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.GridView.DataBind()
at Balticovo.SharePoint.WebParts.CrossSiteDataQueryWebPart.OnLoad(EventArgs e)
The method that is being invocated is GetData. After investigating InnerException with message Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)) it looks like SharePoint want to release resources somwhere:
at Microsoft.SharePoint.Library.SPRequest.ReleaseResources()
at Microsoft.SharePoint.SPRequestManager.Release(SPRequest request)
at Microsoft.SharePoint.SPWeb.Invalidate()
at Microsoft.SharePoint.SPWeb.Close()
at Microsoft.SharePoint.SPWeb.Dispose()
at Balticovo.SharePoint.Extensions.GetCrossSiteData(SPWebApplication webApp, SPCrossSiteDataQuery query)
at Balticovo.SharePoint.TasksTableAdapter.GetData(Guid queryId, Boolean dataForOutlook)
at Balticovo.SharePoint.TasksTableAdapter.GetData(Guid queryId)
But all those methods up to SPWeb.Dispose() I don't dispose anything before I call SPWeb.GetSiteData(SPSiteDataQuery) which then throws an exception.
My Code
Instance of SPWebApplication i get like this - Microsoft.SharePoint.WebControls.SPControl.GetContextWebApplication(HttpContext.Current);
Then i do some stuff like this in function GetCrossSiteData:
foreach (string siteUrl in query.QuerySites)
{
try
{
using (SPSite site = new SPSite(siteUrl))
using (SPWeb web = site.OpenWeb())
{
DataTable dt = web.GetSiteData(query.SiteDataQuery); //Hangs here
....
}
}
}
Any ideas? Thank you.

Turns out that the cause was that for some lists TemplateFeatureId property was set to a template that does not really exist or was changed in some way. As in my case i just recreated those lists and now queries are running fine.
Found this out by this article: http://blog.myitechnology.com/2009/06/fixing-feature-guid-for-list-template.html
Just DO NOT USE that tool to fix the problem - he say's he's modifying the content database (i suppose directly). That's a no-no-no. I just used it to see which lists have the problem.

Related

Pythonnet List<string> unable to convert type

I am using a .dll with python in order to send commands to a motion controller. The majority of requests are OK but I'm facing difficulties when trying the following:
from System.Collections.Generic import List
from System import String
result, response_list, err_string = SMC.ZT(1, List[String], "")
# The Error:
result, list_parameters, err_string = self.SMC.ZT(ctlr_address, List[String], err_string)
System.ArgumentException: Unable to convert type object 'System.RuntimeType' in type 'System.Collections.Generic.List`1[System.String]&'.
to System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
to System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
to System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
to System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
to Python.Runtime.MethodBinder.Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, MethodInfo[] methodinfo)
# Syntax from the docs:
# int ZT(int controllerAddress, out List<string> Parameters, out string errstring)
# controllerAddress: controllerAddress
# Parameters: Parameters
# errString: The failure reason
# return: 0 in success and -1 on failure

TargetInvocationException - Object reference not set to an instance of an object. for Automapper

I am Frequently seeing following error in Windows Event Viewer – Application Error Log. This is happening on Amazon Windows Server.
Web application is in the ASP.net MVC 5. I have recently updated NuGet package for solution just to overcome this error but error still exists.
Event code: 3005
Event message: An unhandled exception has occurred.
Event sequence: 22
Event occurrence: 9
Event detail code: 0
Application information:
Trust level: Full
Application Virtual Path: /
Application Path: WebApPath
Machine name: EC2AMAZ-TUK4T6L
Process information:
Process ID: 9628
Process name: w3wp.exe
Account name: IIS APPPOOL\ AppPoolName
Exception information:
Exception type: TargetInvocationException
Exception message: Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance(Type implType, Object[] arguments, ConstructorCandidate constructor)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)
Object reference not set to an instance of an object.
at AutoMapper.TypeMapFactory.<>c__DisplayClass3_0.<MapDestinationPropertyToSource>b__0(IMemberConfiguration _)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, IProfileConfiguration options, MemberList memberList)
at AutoMapper.ConfigurationStore.<>c__DisplayClass80_0.<CreateTypeMap>b__0(TypePair tp)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at AutoMapper.ConfigurationStore.CreateMap[TSource,TDestination](String profileName, MemberList memberList)
at AP.Web.Services.Services.CustInfoService..ctor(ICustInfoRepository repository)
Thread information:
Thread ID: 22
Thread account name: IIS APPPOOL\ AppPoolName
Is impersonating: False
Stack trace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCreateInstance(Type implType, Object[] arguments, ConstructorCandidate constructor)
at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateInstanceCore(ConstructorCandidate constructor, Object[] arguments, Type implType)
Custom event details:
Not been able to determine why this error coming up. Your help will be greatly appreciated.
Thankyou,
Raj.

Sitecore Logs - Azure Search

Currently I'm seeing the following a lot in my logs, I'm using Sitecore 8.2 rev 2 with azure. The issue only started recently when I added some new indexes to the site for a new microsite. Any ideas of where to start investigating, I've raised with Sitecore too?
ManagedPoolThread #17 22:03:10 ERROR Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Jobs.Job.ThreadEntry(Object state)
Nested Exception
Exception: System.AggregateException
Message: One or more errors occurred.
Source: mscorlib
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, ParallelOptions parallelOptions, Action`2 body)
at Sitecore.ContentSearch.AbstractSearchIndex.PerformUpdate(IEnumerable`1 indexableInfo, IndexingOptions indexingOptions)
Nested Exception
Exception: System.InvalidOperationException
Message: Sequence contains no elements
Source: System.Core
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at Sitecore.ContentSearch.Azure.CloudSearchUpdateContext.Delete(IIndexableId id)
at Sitecore.ContentSearch.SitecoreItemCrawler.Update(IProviderUpdateContext context, IIndexableUniqueId indexableUniqueId, IndexEntryOperationContext operationContext, IndexingOptions indexingOptions)
at Sitecore.ContentSearch.AbstractSearchIndex.<>c__DisplayClass93_2.<PerformUpdate>b__0(IndexableInfo info, ParallelLoopState parallelLoopState)
at System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object )
For those with the same issue,
The patch is Sitecore.Support.158988 found here:
https://github.com/SitecoreSupport/Sitecore.Support.158988
Versions cover Sitecore 8.2 update 1 and update 2.
164633 The CloudSearchUpdateContext.Delete(IIndexableId) fails with an exception in case the search index does not contain any matching documents.
Thanks.
Looks like there is a patch for this from Sitecore, hopefully this will resolve the issue.

error processing a workflow SharePoint 2013

I did a workflow with visual studio workflow foundation
when I run the workflow from sharepoint gives me this error ... does anyone know how to repair the damage ?
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.Utilities.SPUtility.Hex(Char ch)
at Microsoft.SharePoint.SPContentTypeId..ctor(String id)
at Microsoft.SharePoint.Workflow.SPWinOETaskService.CreateTaskWithContentType(Guid taskId, SPWorkflowTaskProperties properties, String taskContentTypeId, HybridDictionary specialPermissions) --- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Workflow.Activities.CallExternalMethodActivity.Execute(ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
at System.Workflow.Runtime.Scheduler.Run()
Without seeing your source code its hard to know for sure what caused the issue, but it looks like you tried to make an unsafe update without using the AllowUnsafeUpdates() function. Updating the Author field on a list item would require this, for example but there are a number of reasons you might need it.
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)

Exception with Subsonic 2.2, SQLite and Migrations

I'm playing with Migrations and created a simple migration like
public class Migration001 : Migration
{
public override void Up()
{
TableSchema.Table testTable = CreateTableWithKey("TestTable");
}
public override void Down()
{
}
}
after executing sonic.exe migrate I'm getting the following output:
Setting ConfigPath: 'App.config'
Building configuration from c:\tmp\MigrationTest\MigrationTest\App.config
Adding connection to SQLiteProvider
Found 1 migration files
Current DB Version is 0
Migrating to 001_Init (1)
There was an error running migration (001_Init):
SQLite error
near "IDENTITY": syntax error
Stack Trace:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] argum
ents, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle
typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] argume
nts, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwn
er)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisib
ilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
at SubSonic.CodeRunner.RunAndExecute(ICodeLanguage lang, String sourceCode, S
tring methodName, Object[] parameters) in D:\#SubSonic\SubSonic\SubSonic.Migrati
ons\CodeRunner.cs:line 95
at SubSonic.Migrations.Migrator.ExecuteMigrationCode(String migrationFile) in
D:\#SubSonic\SubSonic\SubSonic.Migrations\Migrator.cs:line 177
at SubSonic.Migrations.Migrator.Migrate() in D:\#SubSonic\SubSonic\SubSonic.M
igrations\Migrator.cs:line 141
Any hints?
You are probably the only one on the Earth planet to have tried this. I don't think the migration code was ever completed or tested with sqlite, as evidenced by the IDENTITY keyword that shouldn't be used with sqlite. Subsonic is highly sql server centric, so there are many changes required to get all the features working for other databases. There is an improved sqlite provider in one of the forks of subsonic2 on github, but subsonic2 is (currently) a dead project and no github pull requests are being honored.

Resources