Open madelson opened 9 years ago
Yes this is a bug in RazorEngine, thanks for reporting this. This is releated to https://github.com/Antaris/RazorEngine/issues/275 as well. And the workaround is the same:
config.CachingProvider = new DefaultCachingProvider(t => {});
config.DisableTempFileLocking = true;
Can you provide a simplified repro for this (Or at least show me how you implemented your custom identity type)? It is really weird because we try to start a new thread for the sole purpose to get a 'clean' ExecutionContext
(so there is nothing to serialize). However, some things seem to slip through. I'm starting to think that this is some WinAPI specific thing, where the context is saved within the (windows-)thread itself and not the '.net' ExecutionContext
.
I don't have a small repro handy, but here are some details that might be relevant.
Had the same bug with a custom implementation of IIdentity
config.CachingProvider = new DefaultCachingProvider(t => {});
config.DisableTempFileLocking = true;
Fixed it. Thanks!
Any code sample (ideally simplified) reproducing the problem would be appreciated. I already tried fixing that "blindly" but no approach seems to fetch all cases.
@matthid
This error occurs if I use CallContext.LogicalSetData
before method IsolatedRazorEngineService.Create()
and set an entity that is not marked [Serializable].
here is a demo to produce this error.
using RazorEngine.Templating;
using System.Runtime.Remoting.Messaging;
namespace WorkerRole
{
public class User
{
public string Name { get; set; }
}
internal class Program
{
static void Main(string[] args)
{
var user = new User();
CallContext.LogicalSetData("123", user);
using (var service = IsolatedRazorEngineService.Create())
{
}
}
}
}
error is
System.Runtime.Serialization.SerializationException: 'Type 'WorkerRole.User' in assembly 'WorkerRole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.'
I create a new issue to track this problem.
One of the recent upgrades to RazorEngine has led us to start seeing errors like the following:
In this case "some type" and "some assembly" are a custom identity type we use which is not serializable. While we could try to get the creator of that type to be serializable, I wanted to first understand why this was happening and whether there was anything other than make our code 100% remoting compliant in order to keep upgrading RazorEngine.
EDIT: looking into this more, it seems like it's a resurgence of https://github.com/Antaris/RazorEngine/issues/267, where the ExecutionContextLessThread does not seem to be successfully suppressing the execution context.