What is wrong with my project Cannot bind source content type
Hi I hope someone can help me with my project
I m using modelsbuilder mode AppData
I get this error all the time
Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model content type Umbraco.Web.PublishedContentModels.Home.
I have a masterpage and a home template and even if i comment out everything it still get error. If I attatche webconfig rebuild the site its working but everytime i change the code i get this, what Im i doing wrong?
/Christina
Are you seeing this message on the Homepage (and checked the document type of your Homepage is "Home") or is this on all other pages but your homepage works?
If it's happening on other pages then you may have accidentally copied over from your homepage View and not see that the doc type changes on your View in the first line (where it says YourDocTypeAlias below).
Ensure this matches the document type of the page being requested (as that is what is being passed when Umbraco tries to load that page - if it doesn't match it will error.
If you think this is correct then go to the Umbraco backend - look for the Models tab and rebuild your models and look for any health warnings. When you rebuild them post any errors in your log here and I'm sure we can help.
You might want to review what settings you have for Models Builder. Some options mean that for every change you make to DocTypes requires you to manually rebuild the models.
It didn't help I get different .cs files all the time
It starts with Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model type Umbraco.Web.PublishedContentModels.Home.
And then
\AppData\Local\Temp\Temporary ASP.NET Files\vs\961f8b06\3a66f35d\App_Web_home.cshtml.65a2d1ee.4mrpgp38.0.cs
I dont get any errors in modelsbuilder or in code im using Umbraco version 7.10.4
/Christina
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
c: \ Users \ c \ AppData \ Local \ Temp \ Temporary ASP.NET Files \ vs \ 961f8b06 \ 3a66f35d \ AppWebhome.cshtml.65a2d1ee.epzdj9nb.0.cs (42.90): error CS0234: Type or Name Area Name Home is not in the Umbraco.Web.PublishedContentModels namespace (missing a compilation reference?)
Line 42: public class _Page_Views_home_cshtml : Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.Home> {
Line Line 89: BeginContext("~/Views/home.cshtml", 417, 15, true);
Line 90:
Line 91: WriteLiteral(">\r\n <section");
In visual Studio
Severity Code Description Project File Line Suppression State
Warning AD0001 Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The typinitier for Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer`1 triggered an exception.'.
Hi Andy Thanks
I copied this from Modelsbuilder /C
ModelsBuilder is enabled, with the following configuration:
The models factory is enabled.
The API is neither installed nor enabled.
External tools such as Visual Studio cannot use the API.
AppData models are enabled.
Models namespace is Umbraco.Web.PublishedContentModels.
Static mixin getters are enabled. The pattern for getters is "Get{0}".
Tracking of out-of-date models is enabled.
That would mean you're in AppData mode - this is the one we use. With AppData models are only generated when you click the button in the back office. This should create you a file for each doc type in App_Data/Models each of the form *.generated.cs. Have you included these file in to your Visual Studio project?
Can you describe your environment IE how you're running this is it a local dev machine, server, IIS, Visual Studio, etc? May help understand the issue?
Can you check the file App_Data\Models\Home.generated.cs and confirm the namespace is Umbraco.Web.PublishedContentModels.
Also can you send me a copy of the dll generated for the website so I can confirm if the error we're being told is an actual error (pop it in dropbox or something).
What is wrong with my project Cannot bind source content type
Hi I hope someone can help me with my project I m using modelsbuilder mode AppData I get this error all the time
I have a masterpage and a home template and even if i comment out everything it still get error. If I attatche webconfig rebuild the site its working but everytime i change the code i get this, what Im i doing wrong? /Christina
Hi Christina,
Are you seeing this message on the Homepage (and checked the document type of your Homepage is "Home") or is this on all other pages but your homepage works?
If it's happening on other pages then you may have accidentally copied over from your homepage View and not see that the doc type changes on your View in the first line (where it says YourDocTypeAlias below).
Ensure this matches the document type of the page being requested (as that is what is being passed when Umbraco tries to load that page - if it doesn't match it will error.
If you think this is correct then go to the Umbraco backend - look for the Models tab and rebuild your models and look for any health warnings. When you rebuild them post any errors in your log here and I'm sure we can help.
HTH
Steve
Hi Steve
Thanks I use the correct Model on each template, i went to the developer section and went throw the health check . Now its working i hope /Christina
You might want to review what settings you have for Models Builder. Some options mean that for every change you make to DocTypes requires you to manually rebuild the models.
There's a good (but a little dated in places) overview here https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
Thanks!
It didn't help I get different .cs files all the time It starts with
Cannot bind source content type Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent to model type Umbraco.Web.PublishedContentModels.Home.
And thenI dont get any errors in modelsbuilder or in code im using Umbraco version 7.10.4 /Christina
My error
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
c: \ Users \ c \ AppData \ Local \ Temp \ Temporary ASP.NET Files \ vs \ 961f8b06 \ 3a66f35d \ AppWebhome.cshtml.65a2d1ee.epzdj9nb.0.cs (42.90): error CS0234: Type or Name Area Name Home is not in the Umbraco.Web.PublishedContentModels namespace (missing a compilation reference?)
Line
Line 89: BeginContext("~/Views/home.cshtml", 417, 15, true); Line 90:
Line 91: WriteLiteral(">\r\n <section");
In visual Studio Severity Code Description Project File Line Suppression State Warning AD0001 Analyzer 'Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer' threw an exception of type 'System.TypeInitializationException' with message 'The typinitier for Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer`1 triggered an exception.'.
Hi Christina,
Can you confirm which mode you have the Models Builder in. This setting will set how and when models are rebuilt.
Thanks Andy
Hi Andy Thanks I copied this from Modelsbuilder /C
ModelsBuilder is enabled, with the following configuration: The models factory is enabled. The API is neither installed nor enabled. External tools such as Visual Studio cannot use the API. AppData models are enabled. Models namespace is Umbraco.Web.PublishedContentModels. Static mixin getters are enabled. The pattern for getters is "Get{0}". Tracking of out-of-date models is enabled.
Hi Christina,
That would mean you're in AppData mode - this is the one we use. With AppData models are only generated when you click the button in the back office. This should create you a file for each doc type in App_Data/Models each of the form *.generated.cs. Have you included these file in to your Visual Studio project?
Thanks Andy
Hi Andy Thanks yes I have /Christina
Hi,
Can you describe your environment IE how you're running this is it a local dev machine, server, IIS, Visual Studio, etc? May help understand the issue?
Thanks Andy
Hi Andy Many thanks for helping me Im using local machine Windows 10 pro, Visual Studio 2017, MySQL, IIS Express. .NET 4.52
/Christina
Hi Christina,
This is beginning to make less and less sense!
Can you check the file App_Data\Models\Home.generated.cs and confirm the namespace is Umbraco.Web.PublishedContentModels.
Also can you send me a copy of the dll generated for the website so I can confirm if the error we're being told is an actual error (pop it in dropbox or something).
Thanks Andy
Hi Andy Thanks a lot
I have checked the generated files and the namespace is Umbraco.Web.PublishedContentModels
Christina
Hi Christina,
I've looked at the DLL and can confirm the PublishedContentModels namespace is in there and has the home class. Not sure what to suggest next!
Thanks Andy
Thanks a lot Andy
I think I found the error, in the beginning i started building models with the same namespace Umbraco. /Christina
Hi Christina,
Glad you've found it!
is working on a reply...