The problem is that with a virtual path provider, you can't directly
access via System.IO.File, because the data might not even be in a
file. (In our case, we're using a file-backed VPP, but the files are
not sitting in the local virtual directory.)
If it's possible for you to adapt for this case, here's an explanation
about how to do it:
http://msdn.microsoft.com/en-us/library/aa479502.aspx#vpp_vga_topic6
By default, this method of accessing files will work for both VPP and
non-VPP cases, although it's a limited set of IO operations that's
available. I haven't looked through all of the .less code but the
one "File.ReadAllText" case I hit would be easily converted.
Thanks!
Steve
Typically the correct solution would be to wrap up your own
"ReadAllText" routine (use VPP Open method that returns a stream; read
to end of stream & return that string) But I can see how maybe this
particular function is shared with your command-line version, which
couldn't use the VPP functions. Perhaps instead you should be passing
an abstracted Path - either a FilePath or a VirtualPath or whatever -
or better yet, just passing a Stream into
ExtensibleEngine.TransformToCss?
Steve
Chris
(BTW I think you made the right choice doing it via a configurable
element, since VPP may not always be available in every environment
you want to support)
Steve
On Jan 6, 10:16 am, Daniel Hölbling <hoelblin...@gmail.com> wrote:
> @Chris: No problem chris. I rechecked the code and decided to merge it into
> main.
>
> @Steve: I just pushed a new release that adds the requested functionality.
> Please give it a try and report back with suggestions. You can read about
> how to enable the VirtualPathSource from my blogpost about it:http://www.tigraine.at/2010/01/06/less-now-supports-files-from-the-vi...
>
> <http://www.tigraine.at/2010/01/06/less-now-supports-files-from-the-vi...>greetings
dotless.Core.DLL!dotless.Core.VirtualPathSource.GetSource(string key
= "c:\\app\\css\\test.less") + 0x52 bytes
dotless.Core.DLL!dotless.Core.HandlerImpl.Execute() + 0x5e bytes
dotless.Core.DLL!dotless.Core.LessCssHttpHandler.ProcessRequest
(System.Web.HttpContext context = {System.Web.HttpContext}) + 0x7c
bytes
System.Web.dll!
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
() + 0xb6 bytes
I looked at your source and it seems like HandlerImpl is doing a
conversion from virtual->real via MapPath. But VPPs are only really
able to accept virtual path requests - even if the IPathProvider
(which is not a VPP, but Server?) "knows" it maps to a local file in
the vdir, the virtual path provider may not understand the filesystem.
In this case, I could write something to un-map it back to a virtual
path, but I sometimes fall through to the default provider, which will
crash on an absolute path.
Steve
Damn i knew i overlooked smth.
I'll check today and get back to you.
07.01.2010 00:43 schrieb am "SteveEisner" <steve...@gmail.com>:
Hmm, seems like the VirtualPathSource is passing along absolute file
paths rather than virtual paths. Here's what I saw in a request for
[app vdir]/css/test.less
dotless.Core.DLL!dotless.Core.VirtualPathSource.GetSource(string key
= "c:\\app\\css\\test.less") + 0x52 bytes
dotless.Core.DLL!dotless.Core.HandlerImpl.Execute() + 0x5e bytes
dotless.Core.DLL!dotless.Core.LessCssHttpHandler.ProcessRequest
(System.Web.HttpContext context = {System.Web.HttpContext}) + 0x7c
bytes
System.Web.dll!
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execut...
() + 0xb6 bytes
I looked at your source and it seems like HandlerImpl is doing a
conversion from virtual->real via MapPath. But VPPs are only really
able to accept virtual path requests - even if the IPathProvider
(which is not a VPP, but Server?) "knows" it maps to a local file in
the vdir, the virtual path provider may not understand the filesystem.
In this case, I could write something to un-map it back to a virtual
path, but I sometimes fall through to the default provider, which will
crash on an absolute path.
Steve
On Jan 6, 1:21 pm, SteveEisner <steveeis...@gmail.com> wrote: > Thanks Daniel, that was quick! I'l...
ArgumentException: Absolute path information is required.
at
System.Security.Util.StringExpressionSet.CreateListFromExpressions
(String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList
(FileIOPermissionAccess access, AccessControlActions control, String[]
pathListOrig, Boolean checkForDuplicates, Boolean needFullPath,
Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor
(FileIOPermissionAccess access, String path)
at System.Web.InternalSecurityPermissions.PathDiscovery(String
path)
at System.Web.Caching.CacheDependency.Init(Boolean isPublic, String
[] filenamesArg, String[] cachekeysArg, CacheDependency dependency,
DateTime utcStart)
at System.Web.Caching.CacheDependency..ctor(String filename,
DateTime start)
at System.Web.Caching.CacheDependency..ctor(String filename)
at dotless.Core.Abstractions.CssCache.Insert(String fileName,
String css)
at dotless.Core.AspCacheDecorator.TransformToCss(LessSourceObject
source)
at dotless.Core.HandlerImpl.Execute()
at dotless.Core.LessCssHttpHandler.ProcessRequest(HttpContext
context)
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)
which may be the "not cacheable" exception you were talking about?
I can try to help you debug the issue if you'd like, though I'm not
doing anything other than what you described in your blog post.
If it helps, I have similar caching problems with our own VPP. I
ended up using
public override CacheDependency GetCacheDependency(string
virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
{
var coll = new System.Collections.Generic.List<string>();
foreach (string v in virtualPathDependencies)
{
if (FileExists(v)) // <- a call to its own FileExists
override
coll.Add(HttpRuntime.AppDomainAppPath + v);
}
return new System.Web.Caching.CacheDependency(coll.ToArray
(), utcStart);
}
which isn't pretty... it ignores dependencies on anything that doesn't
exist as a physical file. But it gets past the problem!
Steve
> The code I mean is:http://www.dotlesscss.com:8081/viewLog.html?buildId=133&tab=buildResu...
>
> greetings Daniel
>
> On Fri, Jan 8, 2010 at 12:11 AM, Daniel Hölbling <tigra...@tigraine.at>wrote:
>
>
>
> > Ok, Was a busy day so sorry I didn't have time to check the issue.
> > I think it's related to the Server.MapPath abstraction that could be easily
> > disabled if I provide another configuration parameter for it.
> > I'll think about a good way to solve the issue tomorrow.
>
> > greetings Daniel
>
> > On Thu, Jan 7, 2010 at 10:16 AM, Daniel Hölbling <tigra...@tigraine.at>wrote:
>
> >> Damn i knew i overlooked smth.
> >> I'll check today and get back to you.
>
http://blog.waynebrantley.com/2009/12/ultimate-automatic-stylesheet-combining.html
On Jan 14, 6:24 am, Daniel Hölbling <hoelblin...@gmail.com> wrote:
> The latest pinned build should now politely tell you that your PathProvider
> does not support caching and you need to disable it.
> Here the direct link:http://www.dotlesscss.com:8081/viewLog.html?buildId=134&buildTypeId=b...
>
> <http://www.dotlesscss.com:8081/viewLog.html?buildId=134&buildTypeId=b...>greetings
> Daniel
>
> On Thu, Jan 14, 2010 at 12:20 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
> > Also, while at it.
> > I forgot to mention that the new default is not FileSource but
> > AspServerPathSource. FileSource is only used by the Console runner while
> > AspServerPathSource is used by the HttpHandler.
>
> > On Thu, Jan 14, 2010 at 12:13 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
> >> Oh, and while at it.
> >> I found that the sampleweb web.config had a bug in it.
> >> The proper attribute for disabling the cache is
>
> >> cache="false"
> >> not cacheEnabled="false".
>
> >> Since the setting was set to true all the time that mistake got
> >> overlooked. So to fix your problem, just set cache="false". I'll now fix the
> >> exception.
>
> >> On Thu, Jan 14, 2010 at 12:07 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
> >>> Hi Steve,
> >>> yes. That is the problem with the VirtualPathProvider I was talking
> >>> about. You can't cache it since there is no absolute path present.
> >>> You solution looks good, but I already had a safeguard in place that
> >>> should be throwing a custom exception that is far more descriptive than the
> >>> one you are getting. I'll recheck and fix that.
> >>> For now, disable the cache through your web.config and you should be
> >>> fine.
> >>> I'm also looking for ways on how to cache a VPP stream.. (possible just
> >>> in-memory, but let's see)
>
> >>> greetings Daniel
>
Thanks for all the work on this. I can't wait to get my team switched
over to .less
Steve
On Jan 14, 3:24 am, Daniel Hölbling <hoelblin...@gmail.com> wrote:
> The latest pinned build should now politely tell you that your PathProvider
> does not support caching and you need to disable it.
> Here the direct link:http://www.dotlesscss.com:8081/viewLog.html?buildId=134&buildTypeId=b...
>
> <http://www.dotlesscss.com:8081/viewLog.html?buildId=134&buildTypeId=b...>greetings
> Daniel
>
> On Thu, Jan 14, 2010 at 12:20 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
>
>
> > Also, while at it.
> > I forgot to mention that the new default is not FileSource but
> > AspServerPathSource. FileSource is only used by the Console runner while
> > AspServerPathSource is used by the HttpHandler.
>
> > On Thu, Jan 14, 2010 at 12:13 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
> >> Oh, and while at it.
> >> I found that the sampleweb web.config had a bug in it.
> >> The proper attribute for disabling the cache is
>
> >> cache="false"
> >> not cacheEnabled="false".
>
> >> Since the setting was set to true all the time that mistake got
> >> overlooked. So to fix your problem, just set cache="false". I'll now fix the
> >> exception.
>
> >> On Thu, Jan 14, 2010 at 12:07 PM, Daniel Hölbling <hoelblin...@gmail.com>wrote:
>
> >>> Hi Steve,
> >>> yes. That is the problem with the VirtualPathProvider I was talking
> >>> about. You can't cache it since there is no absolute path present.
> >>> You solution looks good, but I already had a safeguard in place that
> >>> should be throwing a custom exception that is far more descriptive than the
> >>> one you are getting. I'll recheck and fix that.
> >>> For now, disable the cache through your web.config and you should be
> >>> fine.
> >>> I'm also looking for ways on how to cache a VPP stream.. (possible just
> >>> in-memory, but let's see)
>
> >>> greetings Daniel
>