problem creating new document with uTube datatype programmatically
Hi All,
When trying to create a new document with the uTube datatype, from either xslt, or a usercontrol, the creation fails with:
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
--
This is using something like this:
Document uTubeDocument = Document.MakeNew("New uTube document", DocumentType.GetByAlias("uTubeVideo"), new User(0), parentId);
And before assigning any value to the uTube property - changing the uTube datatype to a textbox makes the creation of the document go through.
Yes, I'm using the single picker, and the stacktrace is:
umbracoXsltExtensionExtension added: urn:uTube.XSLT, Library0,119291418322720,000021 umbracoMacroAfter adding extensions0,1193112532458730,000020 umbracoMacroBefore performing transformation0,1221314440801830,002820 umbracoMacro InnerExceptionAn error occurred during a call to extension function 'CreateCompetitionEntry'. See InnerException for a complete description of the error. An error occurred during a call to extension function 'CreateCompetitionEntry'. See InnerException for a complete description of the error. at System.Xml.Xsl.Runtime.XmlExtensionFunction.Invoke(Object extObj, Object[] args) at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args) at System.Xml.Xsl.CompiledQuery.Query.<xsl:template match="/">(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current, Double {urn:schemas-microsoft-com:xslt-debug}position, Double {urn:schemas-microsoft-com:xslt-debug}last, IList`1 {urn:schemas-microsoft-com:xslt-debug}namespaces) in D:\\public\xslt\YouTubeFormular.xslt:line 104 at System.Xml.Xsl.CompiledQuery.Query.<xsl:apply-templates>(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator , Double , Double ) at System.Xml.Xsl.CompiledQuery.Query.Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.CompiledQuery.Query.Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) at umbraco.macro.GetXsltTransformResult(XmlDocument macroXML, XslCompiledTransform xslt, Dictionary`2 parameters) at umbraco.macro.loadMacroXSLT(macro macro, MacroModel model, Hashtable pageElements)0,4133681794753240,291237 umbracoMacro InnerExceptionObject reference not set to an instance of an object. Object reference not set to an instance of an object. at project.XsltExtensions.CreateCompetitionEntry(String name, String address, String zipcode, String city, String email, String telephone, String youtubeUrl)0,4153502749651140,001982
I switched to using the following, with the input coming from a regular textbox
This is still puzzling me. To my knowledge, Document.MakeNew doesn't do anything with the properties/data-type ... it just creates a the document stub (with empty/null properties).
What happens when you call "DocumentType.GetByAlias" on it's own?
Yeah, it puzzles me to, but it works when I change the datatype to a textstring from the single picker, so it seems to be connected to that somehow - you are not able to reproduce ?
Sorry for taking a while to get back to you - I've only just had chance to try to reproducing this problem.
In my test it works fine for me; creates the new document with no errors/exceptions. My doc-type only contained a few textstring properties and one "uTube Single Video Picker" property. Which worked fine.
Ah, I haven't tested against using MySQL ... must take a look at that sometime - still curious what the problem could be? I'm not doing anything 'out of the ordinary' with the uTube data-type (uses standard Umbraco API).
problem creating new document with uTube datatype programmatically
Hi All,
When trying to create a new document with the uTube datatype, from either xslt, or a usercontrol, the creation fails with:
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
--
This is using something like this:
And before assigning any value to the uTube property - changing the uTube datatype to a textbox makes the creation of the document go through.
/Søren
Hi Søren,
Which uTube data-type are you using? (Is it the Single Video Picker?)
Could you post the rest of the exception's stack-trace, we might be able to pinpoint the issue.
Thanks, Lee.
Hi Lee,
Thank you for the reply.
Yes, I'm using the single picker, and the stacktrace is:
I switched to using the following, with the input coming from a regular textbox
so the package is still extremely useful, but it would be great if the other approach could be accomplished :)
/Søren
Hi Søren,
Not sure what else is going on in your "CreateCompetitionEntry" method, does the error occur when you call "Document.MakeNew" or elsewhere?
I've taken a look over the uTube codebase to see where there might be an issue, but I don't see any problems with the code.
Hmmm... not sure what to suggest.
Cheers, Lee.
Hi Lee,
Yes, only thing going on in the method is
(the rest is outcommented for testing this issue.)
/Søren
Hi Søren,
This is still puzzling me. To my knowledge, Document.MakeNew doesn't do anything with the properties/data-type ... it just creates a the document stub (with empty/null properties).
What happens when you call "DocumentType.GetByAlias" on it's own?
Cheers, Lee.
Hi Lee,
Yeah, it puzzles me to, but it works when I change the datatype to a textstring from the single picker, so it seems to be connected to that somehow - you are not able to reproduce ?
/Søren
Hi Søren,
Sorry for taking a while to get back to you - I've only just had chance to try to reproducing this problem.
In my test it works fine for me; creates the new document with no errors/exceptions. My doc-type only contained a few textstring properties and one "uTube Single Video Picker" property. Which worked fine.
Not sure what to suggest next.
- Lee
Seems my post dissappeared... Anyways here it is somewhat reconstructed :)
Thanks for taking the time to respond. Could it somehow be an issue that I'm using MySql ?
/Søren
Hi Søren,
Ah, I haven't tested against using MySQL ... must take a look at that sometime - still curious what the problem could be? I'm not doing anything 'out of the ordinary' with the uTube data-type (uses standard Umbraco API).
Cheers, Lee.
is working on a reply...