Copied to clipboard

Flag this post as spam?

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


  • Phil L 3 posts 73 karma points
    Nov 27, 2017 @ 17:55
    Phil L
    0

    Using Models Builder Api with SQL Server

    Howdy Y'all,

    I'm rather new to umbraco so I'm hoping that someone will be able to help me with an issue that I am having.

    I'm having an issue where the only way that the models will work for my site is if I have the models builder set to PureLive. I am trying to get it to work with either AppData or nothing, so that I could have it use the models builder api. Every time I try to generate the models, either through the back office if using AppData or through the VS custom tool when using the api route, I get this rather unhelpful error which I will include below.

    I will note that when I create a seperate test project and elected to use the SQL CE route instead of SQL server both AppData and the api with the custom tool worked just fine. So it leads me to believe that it is an issue with my using SQL server however I can't figure out why.

    I have watched all the relevant videos on umbraco.tv as well as read through every setup guide that I could find and none of them worked for me.

    I'll also note that I am currently running the site through IIS locally and the SQL server is run on a different machine, not sure if that impacts this or not.

    Thanks.

    UmbracoModelsBuilder: Starting v3.0.6.97
    UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
    {"Message":"An error has occurred.","ExceptionMessage":"The type initializer for 'File' threw an exception.","ExceptionType":"System.IO.IOException","StackTrace":"   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)\r\n   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)\r\n   at Umbraco.ModelsBuilder.ReferencedAssemblies.<>c.<.cctor>b__2_2(String x) in X:\\Projects\\Umbraco\\ModelsBuilder\\Zbu.ModelsBuilder\\Umbraco.ModelsBuilder\\ReferencedAssemblies.cs:line 24\r\n   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary`2 files) in X:\\Projects\\Umbraco\\ModelsBuilder\\Zbu.ModelsBuilder\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n   at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 65\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"The type initializer for 'File' threw an exception.","ExceptionType":"System.TypeInitializationException","StackTrace":"   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'System.IO.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":"   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)\r\n   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)\r\n   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)\r\n   at System.Type.GetType(String typeName, Boolean throwOnError)\r\n   at Roslyn.Utilities.ReflectionUtil.GetTypeFromEither(String contractName, String desktopName)\r\n   at Roslyn.Utilities.PortableShim.File..cctor()"}}}
    UmbracoModelsBuilder:    at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
        at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
        at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)
    
  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Dec 02, 2017 @ 12:01
    Alex Skrypnyk
    0

    Hi Phil

    Welcome to our forum!!!

    What version of Umbraco are you using?

    Try to use Dll mode, I think it's really nice if you are not changing your doctypes very often.

    Thanks,

    Alex

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Dec 02, 2017 @ 12:02
    Alex Skrypnyk
    0

    Also, check please that your site has right permissions to folders, it should be like that - https://our.umbraco.org/documentation/getting-started/setup/install/permissions

  • Phil L 3 posts 73 karma points
    Dec 04, 2017 @ 15:03
    Phil L
    0

    The version I was using was 7.7.4. I had tried it with all different types of models builder (Dll, AppData, Api) and none of them had worked.

    So after exhausting everything I could think of I decided to just delete the entire project and start over from scratch. This time nuget installed the 7.7.6 version of umbraco and low and behold when I finished getting everything set up I went and tried to generate the models and this time it worked as intended.

    I have absolutely no idea why or what was causing it to break before but I'm happy that it is now working properly.

    @Alex just to follow up, I did have the correct permissions on the folder itself and I needed to use Api mode as these models are going to be shared across several different projects and will need to be extended in various cases.

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Dec 04, 2017 @ 15:06
    Alex Skrypnyk
    0

    This is the really strange issue, maybe something in the log?

  • Phil L 3 posts 73 karma points
    Dec 04, 2017 @ 15:11
    Phil L
    0

    Is there a different log besides what I was able to get from the output window? All I was able to find when I was trying to debug this was what I had included above.

    I did find when I was Googling the specific error that I was getting that there were like two other people that had reported this on the custom tools github page. Most of the comments centered around there being incompatibilities with the tool and the version of Umbraco that was installed but no one really knew for sure.

Please Sign in or register to post replies

Write your reply to:

Draft