ModelsBuilder.Original: The type initializer for 'File' threw an exception.
Hi guys
I’ve just started up a totally empty instance of Umbraco, I’ve created some simple DocumentTypes with a couple of properties and the model builder keeps throwing an error.
I’ll include the stack trace below, any help would be greatly appreciated.
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 X:\Projects\Umbraco\ModelsBuilder\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\ReferencedAssemblies.cs:line 24
at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Buffer
1…ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)
at Umbraco.ModelsBuilder.ReferencedAssemblies.<>c.<.cctor>b__2_1() in X:\Projects\Umbraco\ModelsBuilder\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\ReferencedAssemblies.cs:line 23
at System.Lazy1.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 X:\Projects\Umbraco\ModelsBuilder\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 108
at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.BuildModels() in X:\Projects\Umbraco\ModelsBuilder\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 35
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15
I had this same problem and did not find any of the above solutions to work for me. What did work was removing the reference to System.IO.FileSystem from the project. This would probably not work as well if you are storing media items locally, but my project uses the Azure blob storage provider. What seems to end up happening is that the project uses whatever assembly it can find.