Autogenerated doctype templates do not compile in the visual studio editor. I created the templates in Umbraco version 7.4.0-RC1, and the generated cshtml looks like this:
Severity Code Description Project File Line
Error CS0234 The type or namespace name 'Article' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)
It seems the class ContentModels.Article cannot be found.
Quick answer: in PureLive the models exist only in memory at runtime, so Visual Studio does not know about them and reports errors. If you run the template, it should actually work.
If you want Visual Studio to know about your models, they do need to exist in a proper DLL so the correct solution is indeed to go for value="Dll" and generate the DLL.
If everything is properly configured in web.config then VS should find the generated DLL in the ~/bin directory, and be happy with your models.
Currently preparing a blog post on that topic w/more details.
I had an Umbraco 7.4 project which was installed and run from outside of Visual Studio, and which I wanted to run from within Visual Studio. I got an error message (below), and a search for it brought me here. Below are the exact steps to get it working.
Error message Visual Studio gave me:
the type or namespace "[something]" does not exist in the namespace umbraco.web.publishedcontentmodels
For me, the [something] corresponded to the name of a document type. The solution below assumes this is the case.
2) Run the website again from outside Visual Studio
3) Go into Settings > Document Types > [Something] document type
4) On the Save button, you should now see a button to open a menu (if not, poke web.config and reload). Click "save and generate models".
5) Repeat this for each instance of the error message.
6) Run the project from Visual Studio.
This got it working for me. By my understanding, you will now have to "Save and generate models" each time changes are made, to maintain Visual Studio compatibility.
Autogenerated templates do not compile
Autogenerated doctype templates do not compile in the visual studio editor. I created the templates in Umbraco version 7.4.0-RC1, and the generated cshtml looks like this:
The error is
Severity Code Description Project File Line Error CS0234 The type or namespace name 'Article' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)
It seems the class ContentModels.Article cannot be found.
How do I get this to compile?
Found the solution. It should be enough to edit the web.config like this:
Then rebuild the models on the datatypes in the Umbraco backend.
Just found this problem on my first template. Changed
to
Then rebuilt models in the Developer Section ModelBuilder tab. Nothing changes. The back end says "Models out of date"
Template still shows an error in VS2015.
Craig
Quick answer: in PureLive the models exist only in memory at runtime, so Visual Studio does not know about them and reports errors. If you run the template, it should actually work.
If you want Visual Studio to know about your models, they do need to exist in a proper DLL so the correct solution is indeed to go for
value="Dll"
and generate the DLL.If everything is properly configured in web.config then VS should find the generated DLL in the ~/bin directory, and be happy with your models.
Currently preparing a blog post on that topic w/more details.
Blog post is here: http://www.zpqrtbnk.net/posts/beyond-purelive
I had an Umbraco 7.4 project which was installed and run from outside of Visual Studio, and which I wanted to run from within Visual Studio. I got an error message (below), and a search for it brought me here. Below are the exact steps to get it working.
Error message Visual Studio gave me:
For me, the [something] corresponded to the name of a document type. The solution below assumes this is the case.
Solution:
1) Go into Web.config, and change the line
<add key="Umbraco.ModelsBuilder.ModelsMode" value="PureLive" />
to
<add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll" />
2) Run the website again from outside Visual Studio
3) Go into Settings > Document Types > [Something] document type
4) On the Save button, you should now see a button to open a menu (if not, poke web.config and reload). Click "save and generate models".
5) Repeat this for each instance of the error message.
6) Run the project from Visual Studio.
This got it working for me. By my understanding, you will now have to "Save and generate models" each time changes are made, to maintain Visual Studio compatibility.
Hey thanks for that!
But i got a Problem.. When i click "Save and generate models" i get an error:
What can I do?
EDIT I changed the value from Dll to LiveDll. Now it works. In this mode it creates always all models for all Document Types.
Read more about the ModelsModes on this Link: https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes
I did exactly like you said but it wasn't working. In step 2, after changed the line
to
I couldn't run the website again, The error was
What should i do?
Phong
Thanks! This worked for me.
You probably did this anyway, but did you build the solution after you changed the value?
I get this error CS0426: The type name 'Web' does not exist in the type 'Umbraco.Web.PublishedContentModels.* any clue?
is working on a reply...