2

I am doing some background thread task in sitefinity. previously i was getting exception at the line.

Config.Get().ConnectionStrings. To overcome it i have sent dummy ashx request to my site and able to get connection string and connect ot db.

Now when trying to access DynamicContent via code

DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type itemType = TypeResolutionService.ResolveType(key);
            DynamicContent item = dynamicModuleManager.GetDataItem(itemType, id);

            return item;

I am getting above mentioned error.

Any idea how to overcome this The referenced OpenAccessContext or 'IObjectScope' is already closed (UnsynchronizedPMProxy). error?

1 Answer 1

0

I suggest to try this approach to get the connection string:

var connectionString = Config.Get<DataConfig>().ConnectionStrings.Values.FirstOrDefault();
2
  • 1
    Thanks Veseline. I have already tried it but not work always. For instance if i am starting some background task in application start then it throws error (unless make that thread sleep for a while) Commented Jul 5, 2014 at 17:47
  • In this case the Config may not have been initialized. Make sure you do it in Bootstrapper.Initialized event. More about it here: sitefinity.com/documentation/documentationarticles/… Commented Jul 7, 2014 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.