Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.net 4 #316

Open
AlexCuse opened this issue Jun 27, 2015 · 2 comments
Open

.net 4 #316

AlexCuse opened this issue Jun 27, 2015 · 2 comments

Comments

@AlexCuse
Copy link
Collaborator

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()
@AlexCuse
Copy link
Collaborator Author

@AlexCuse
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant