SquishIt
SquishIt copied to clipboard
.net 4
Seems our mutex usage is problematic running under .net 4
ex:
Test 'SquishIt.Tests.StylePreprocessorPipelineTests.WithPreprocessor_Uses_Instance_Preprocessors' failed: System.MethodAccessException : Attempt by security transparent method 'SquishIt.Framework.Utilities.FilePathMutexProvider.CreateSharableMutex(System.String)' to access security critical method 'System.Threading.Mutex..ctor(Boolean, System.String, Boolean ByRef, System.Security.AccessControl.MutexSecurity)' failed.
Assembly 'SquishIt.Framework, Version=0.9.8.1, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
Utilities\FilePathMutexProvider.cs(96,0): at SquishIt.Framework.Utilities.FilePathMutexProvider.CreateSharableMutex(String name)
Utilities\FilePathMutexProvider.cs(76,0): at SquishIt.Framework.Utilities.FilePathMutexProvider.CreateSharableMutexForPath(String normalizedPath)
Utilities\FilePathMutexProvider.cs(47,0): at SquishIt.Framework.Utilities.FilePathMutexProvider.GetMutexForPath(String path)
Utilities\CriticalRenderingSection.cs(18,0): at SquishIt.Framework.Utilities.CriticalRenderingSection..ctor(String path)
Base\BundleBase.Rendering.Internals.cs(251,0): at SquishIt.Framework.Base.BundleBase`1.RenderRelease(String key, String renderTo, IRenderer renderer)
Base\BundleBase.Rendering.Internals.cs(155,0): at SquishIt.Framework.Base.BundleBase`1.Render(String renderTo, String key, IRenderer renderer)
StylePreprocessorPipelineTests.cs(122,0): at SquishIt.Tests.StylePreprocessorPipelineTests.WithPreprocessor_Uses_Instance_Preprocessors()
http://stackoverflow.com/a/23885583
This is kinda crappy but I guess it works if I understand right.
public CriticalRenderingSection(string path)
{
try
{
mutex = MutexProvider.GetMutexForPath(path);
mutex.WaitOne();
}
catch
{
mutex = null;
}
}
Medium trust in general is going to be more painful now, some of the directory manipulation stuff needed for preprocessing fails when invoked as well. Core functionality should still work OK.