Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Michael 125 posts 409 karma points
    Dec 14, 2016 @ 14:08

    Hi all,

    Trying umbraco models builder but having this message:

    Failed to build models.
    The type initializer for 'File' threw an exception.
    at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
    at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
    at Umbraco.ModelsBuilder.ReferencedAssemblies.<>c.<.cctor>b__2_2(String x) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\ReferencedAssemblies.cs:line 24
    at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
    at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
    at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
    at Umbraco.ModelsBuilder.ReferencedAssemblies.<>c.<.cctor>b__2_1() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\ReferencedAssemblies.cs:line 23
    at System.Lazy`1.CreateValue()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    at System.Lazy`1.get_Value()
    at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.GenerateModels(String modelsDirectory, String bin) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 108
    at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.BuildModels() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 35

    Thanks, Mike

  • Piotr 1 post 71 karma points
    Nov 01, 2017 @ 10:45

    Hi Michael,

    Have you managed to resolve this issue? I experience the same problem, it works in dev environment, but after deploying to production server I'm not able to generate models. I found this article, but creating new bindingRedirect didn't help.

    Thanks, Piotr

  • Benoit Cornette 29 posts 169 karma points
    Nov 03, 2017 @ 15:48
    Benoit Cornette

    Hi Mike,

    Did you adjust the Web.config file to "AppData" or something else? After that you can generate the models in the "Developer" section in the Umbraco backend. Should do the trick... If not, try to rebuild the solution in Visual Studio.

    Kind regards,


  • SSA 2 posts 92 karma points
    Nov 28, 2017 @ 10:51

    Hi Piotr,

    Today I was facing the same issue, using the "AppData" mode for the ModelsBuilder. The binding redirect seems to work, only I had to use a different version.

    In my /bin folder is a System.IO.FileSystem.dll with version so in my case the binding redirect turned out like this:

        <assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

    I actually found the right assembly version by listing all assemblies and filtering on FileSystem:

    var items = AppDomain.CurrentDomain.GetAssemblies();
    items.Where(a => a.FullName.Contains("FileSystem")).ToList()



  • Gary Hammett 3 posts 73 karma points
    Jan 22, 2019 @ 22:31
    Gary Hammett

    This worked for me! Thanks for posting.

  • Angelo 103 posts 226 karma points
    Dec 05, 2019 @ 17:47

    can any one help me after upgrading form 7.14 to 7.15.3 ...a get this error when building models :(

    tried everything and nothing any ideas ?

    thank you


  • Dmitriy 168 posts 588 karma points
    Mar 30, 2020 @ 19:17

    The same issue in Umbraco 7.15.3 in live invironment, everything is ok in localhost.

    I just removed System.IO.FileSystem.dll from bin folder and everything became fine. Actually I don't know why that happened, I checked the pure umbraco solution and there was the same file in bin folder.

    Wondering what went wrond on live environment

Please Sign in or register to post replies

Write your reply to: