I'm looking for a way to create new nodes from a class library to synchronize data between an external database and Umbraco. Using the Document.MakeNew method works fine when called from an Umbraco web application. But it throws an exception when being called from a class library that has all the same configuration items.
Thanks for your answers. It's a shame we can't do this import in a Windows Service running in the background! I've tried the CMSImport package and it seems to work fine. We'll obviously need the Pro version.
Document.MakeNew from class library
Hi all,
I'm looking for a way to create new nodes from a class library to synchronize data between an external database and Umbraco. Using the Document.MakeNew method works fine when called from an Umbraco web application. But it throws an exception when being called from a class library that has all the same configuration items.
Code:
The type initializer for 'umbraco.UmbracoSettings' threw an exception.
Value cannot be null. Parameter name: str
at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
at System.Web.InternalSecurityPermissions.get_AppPathDiscovery()
at System.Web.HttpRuntime.get_AppDomainAppPath()
at umbraco.GlobalSettings.get_FullpathToRoot()
at umbraco.UmbracoSettings..cctor()
Strange thing is, the node is created in the Umbraco database but it's not published.
Regards,
Erik
The Umbraco API won't work outside of an Umbraco environment. Also see this answer: http://stackoverflow.com/questions/3873952/umbraco-document-getproperty-value-throws-null-reference-exception#3899490
Jeroen
Hi,
As Jeroen says it's not possible at the moment. For importing data you might want to checkout CMSImport it supports SQL Server in the free version.
Cheers,
Richard
Hi Jeroen and Richard,
Thanks for your answers. It's a shame we can't do this import in a Windows Service running in the background!
I've tried the CMSImport package and it seems to work fine. We'll obviously need the Pro version.
Erik
Hi Erik,
I think it will change in the future but for now it's not possible. Thanks for trying CMSImport.
Thanks,
Richard
is working on a reply...