LocalizedString Fails in Certain Scenarios

Topics: Core, Customizing Orchard, General
Aug 14, 2013 at 5:25 PM
I've had issues where the T("") convention fails completely during certain situations. The one I can duplicate and am currently facing is within a Web Api method. The Web Api method accepts a Multipart Form data. Here is the method where the T("") will completely fail...
// Read the form data and return an async task.
            var task = Request.Content.ReadAsMultipartAsync(provider).
                ContinueWith(t =>
                         var test = T("This is a test");
I'm not sure how to proceed because as soon as I call ContentManager within this method something downstream in the Orchard guts references T("") and it throws an exception. Otherwise I would simply not use T() within my method and be able to move forward.
Aug 14, 2013 at 6:40 PM
Put the conversion outside the ContinueWith ?
Aug 15, 2013 at 4:09 AM
The problem is inside the ContinueWith a bunch of work is done with ContentManager and other Orchard services within that process. It is within these processes the localization fails. I just used this simple example for brevity to show that the localization gets lost (I could simply call T = NullLocalizer.Instance within the ContinueWith to reinstantiate T as well). I've found a workaround by simply not using the async paradigm but it seems like this would be a problem for other situations as well.