Вопрос

The situation

I'm developing a pure ServiceStack/Razor application (no MVC4 or Web API) using licensed ServiceStack 4.0.12. I have a view (cshtml) that references a Javascript file which is transpiled from a dart project (using AngularDart).

For convenience, I nest the dart project folder within the ServiceStack project, but do not include it in Visual Studio. I then work on my dart project using Dart Editor separately.

The overall project structure looks something like this:

MyApp.csproj
Global.asax.cs
\Controllers           <- contains the IService formatted by 'Views\index.cshtml'.
\Dart                  <- not included in Visual Studio project.
     \packages
     \build
           \myapp.dart.js
     \lib
     \web
         \myapp.dart
\Views                 
      \index.cshtml    <- references 'myapp.dart.js'

I set up a simple, working ServiceStack/Razor 'Hello World' in Local IIS, then switched to Dart Editor to set up my dart project.

The problem

Imagine my frustration switch back a few minutes later only to find that my beautiful 'Hello World' has been replaced by 'Snapshot of Index'. Without having touched a single line of code, config or re-compiled.

When I switched to IIS Express, the ServiceStack/Razor app would work fine again. Same code, no changes to config or re-compilation.

After losing hair for several hours, poking various config settings and playing with a sandbox project to no effect, I happened to move the 'Dart' folder OUT of the VS project folder, modified Web.config and refreshed the app - and the app worked again!

Sure enough, when I put the 'Dart' folder back into the project folder, modified Web.config and refreshed - the app reverted to Snapshot again.

The question

Of course, my question is can anyone tell me why nesting the Dart project folder within the ServiceStack project folder causes ServiceStack.Razor to stop rendering views?

Edit: More info

The Dart folder contains the following file types:

  • pubspec.yaml
  • pubspec.lock
  • *.js
  • *.dart
  • *.json
  • a shortcut to the 'packages' folder from the 'web' folder (DartEditor creates this)

Edit: More info from Mythz's advice

?debug=requestinfo
yielded the following StartUpErrors:

"StartUpErrors": [
        {
            "ErrorCode": "UnauthorizedAccessException",
            "Message": "Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.",
            "StackTrace": "[Object: 12/03/2014 4:44:51 PM]:\n[REQUEST: ]\nSystem.UnauthorizedAccessException: Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.\r\n   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n   at System.IO.FileSystemEnumerableIterator`1.CommonInit()\r\n   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r\n   at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)\r\n   at ServiceStack.VirtualPath.FileSystemVirtualDirectory.GetMatchingFilesInDir(String globPattern)\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()\r\n   at System.Linq.Enumerable.<DistinctIterator>d__81`1.MoveNext()\r\n   at ServiceStack.Formats.MarkdownFormat.<FindMarkdownPages>d__7.MoveNext()\r\n   at ServiceStack.Formats.MarkdownFormat.RegisterMarkdownPages(String dirPath)\r\n   at ServiceStack.Formats.MarkdownFormat.Register(IAppHost appHost)\r\n   at ServiceStack.ServiceStackHost.LoadPlugin(IPlugin[] plugins)",
            "Errors": []
        },
        {
            "ErrorCode": "UnauthorizedAccessException",
            "Message": "Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.",
            "StackTrace": "[Object: 12/03/2014 4:44:51 PM]:\n[REQUEST: ]\nSystem.UnauthorizedAccessException: Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.\r\n   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n   at System.IO.FileSystemEnumerableIterator`1.CommonInit()\r\n   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r\n   at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)\r\n   at ServiceStack.VirtualPath.FileSystemVirtualDirectory.GetMatchingFilesInDir(String globPattern)\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()\r\n   at System.Linq.Enumerable.<DistinctIterator>d__81`1.MoveNext()\r\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\n   at ServiceStack.EnumerableExtensions.Each[T](IEnumerable`1 values, Action`1 action)\r\n   at ServiceStack.Razor.Managers.RazorViewManager.Init()\r\n   at ServiceStack.Razor.RazorFormat.Init()\r\n   at ServiceStack.Razor.RazorFormat.Register(IAppHost appHost)",
            "Errors": []
        },
        {
            "ErrorCode": "UnauthorizedAccessException",
            "Message": "Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.",
            "StackTrace": "[Object: 12/03/2014 4:44:51 PM]:\n[REQUEST: ]\nSystem.UnauthorizedAccessException: Access to the path 'D:\\Semi Da Vinci\\git\\BEAU\\BEAU.Beaufort.git\\Source\\BEAU.Beaufort.Website\\Dart\\packages\\analyzer' is denied.\r\n   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n   at System.IO.FileSystemEnumerableIterator`1.CommonInit()\r\n   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)\r\n   at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)\r\n   at ServiceStack.VirtualPath.FileSystemVirtualDirectory.GetMatchingFilesInDir(String globPattern)\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at ServiceStack.VirtualPath.AbstractVirtualDirectoryBase.<GetAllMatchingFiles>d__0.MoveNext()\r\n   at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()\r\n   at System.Linq.Enumerable.<DistinctIterator>d__81`1.MoveNext()\r\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\n   at ServiceStack.EnumerableExtensions.Each[T](IEnumerable`1 values, Action`1 action)\r\n   at ServiceStack.Razor.Managers.RazorViewManager.Init()\r\n   at ServiceStack.Razor.RazorFormat.Init()\r\n   at ServiceStack.Razor.RazorFormat.Register(IAppHost appHost)\r\n   at ServiceStack.ServiceStackHost.LoadPlugin(IPlugin[] plugins)",
            "Errors": []
        }
    ],

On closer inspection, the folders underneath /packages are all symlinks to the original libraries in the system cache (more info here: https://www.dartlang.org/tools/pub/faq.html).

Seems like ServiceStack is tripping up on these symlinks.

Это было полезно?

Решение

There was an issue with being unable to scan symbolic links in Windows using .NET's File IO API's which are now instead being logged as warnings in this commit. This fix is available in MyGet now or in the next v4.0.13+ on NuGet.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top