I have an old Sharepoint 2010 project which uses Microsoft.SharePoint.Linq.DataContext objects generated using the tool SPMetal.
Recently I'm seeing the following error when accessing entities in the DataContext. The error is not consistent and occurs infrequently
Unknown SPRequest error occurred. More information: 0x80010102 0x80010102
the error has the following definition "Attempted to make calls on more than one thread in single threaded mode"
This has occurred it multiple areas of code all of which share an instance of the Datacontext.
The example code does work most of the time and is the most simple example I can find. Does anyone have an insight into the cause of this problem
var ethnicity = from d in
ContextFactory.Instance.Ethnicities.OfType<Ethnicity>()
select new EthnicityDTO
{
ID = d.Id,
Title = d.Title,
TitleWelsh = d.TitleWelsh,
EthnicGroup = d.EthnicGroupDTO
};
public class ContextFactory
{
private static NightOutEntityDataContext _instance;
private static object syncRoot = new Object();
public static NightOutEntityDataContext Instance
{
get
{
if (_instance == null)
{
lock (syncRoot)
{
if (_instance == null)
_instance = new
NightOutEntityDataContext(EntityUtils.SiteUrl);
}
}
return _instance;
}
}
Where NightOutEntityDataContext is the class auto generated via SPMetal
User contributions licensed under CC BY-SA 3.0