Copied to clipboard

Flag this post as spam?

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


  • John Smith 1 post 21 karma points
    Oct 25, 2012 @ 17:05
    John Smith
    0

    Creating a Document error on 4.10

    Trying to create a document using the code found on http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document and I keep getting an error on the Document.MakeNew line.

    Here are the details of the error:

    System.InvalidOperationException was unhandled
    Message=Current has not been initialized. You must initialize Current before trying to read it.
    Source=Umbraco.Core
    StackTrace:
    at Umbraco.Core.ObjectResolution.ResolverBase`1.get_Current() in c:\Program Files (x86)\teamcity\buildAgent\work\4af3fd8212e189a2\src\Umbraco.Core\ObjectResolution\ResolverBase.cs:line 31
    at umbraco.cms.businesslogic.datatype.controls.Factory.GetNewObject(Guid DataEditorId)
    at umbraco.cms.businesslogic.datatype.controls.Factory.DataType(Guid DataTypeId)
    at umbraco.cms.businesslogic.datatype.DataTypeDefinition.get_DataType()
    at umbraco.cms.businesslogic.property.Property.MakeNew(PropertyType pt, Content c, Guid versionId)
    at umbraco.cms.businesslogic.Content.addProperty(PropertyType pt, Guid versionId)
    at umbraco.cms.businesslogic.Content.createNewVersion(DateTime versionDate)
    at umbraco.cms.businesslogic.Content.CreateContent(ContentType ct)
    at umbraco.cms.businesslogic.web.Document.MakeNew(String Name, DocumentType dct, User u, Int32 ParentId)
    at MyCustomProgram.Program.Main(String[] args) in c:\Program Files (x86)\MyCustomProgram\MyCustomProgram\Program.cs:line 18
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:

    In doing some digging it appears that error is thrown on this line in the Property.cs file of Umbraco.

    interfaces.IData d = pt.DataTypeDefinition.DataType.Data;

    pt.DataTypeDefinition.DataType has the exception of "Current has not been initialized. You must initialize Current before trying to read it.".

  • Stephen 767 posts 2273 karma points c-trib
    Oct 26, 2012 @ 08:59
    Stephen
    0

    In what context are you running the code? From some code-behind in the website? Or from some console app? From the stack trace it looks like you are running "MyCustomProgram" and so you would be trying to run the code from outside the web application. I am afraid that is not supported at the moment, the code that you use is meant to be used from within the web application, eg in code-behind.

Please Sign in or register to post replies

Write your reply to:

Draft