Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Need help... on LinqToUmbraco without a WebContext...
I have a console app that need to use LinqToUmbraco generated Entities.
CmsDataContext class that generated from the "Export to .Net" umbraco DocumentTypes .
What i did...
static void Main(string[] args)
{
using (var dataProvider = new NodeDataProvider("umbraco.config", true))
using (var ctx = new CmsDataContext(dataProvider))
var latestPost = (from post in ctx.BlogPostDTs
orderby post.UpdateDate descending
select post).First();
}
===============
RECEIVING following ERROR. Please suggest what i am doing wrong???
System.TypeInitializationException was unhandled
Message="The type initializer for 'umbraco.UmbracoSettings' threw an exception."
Source="businesslogic"
TypeName="umbraco.UmbracoSettings"
StackTrace:
at umbraco.UmbracoSettings.get_ForceSafeAliases()
at umbraco.cms.helpers.Casing.SafeAliasWithForcingCheck(String alias)
at umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml[T](XElement xml, T node)
at umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at EvaluateLinqToUmbracoConsoleApp.Program.Main(String[] args) in G:\Bharath\umbraco\EvaluateLinqToUmbracoConsoleApp\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ArgumentNullException
Message="Value cannot be null.\r\nParameter name: str"
Source="mscorlib"
ParamName="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()
InnerException:
LINQ to Umbraco doesn't work in a console application due to the way it needs to resolve the aliases of the nodes.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
LinqToUmbraco in console application. Need help.
Need help... on LinqToUmbraco without a WebContext...
I have a console app that need to use LinqToUmbraco generated Entities.
CmsDataContext class that generated from the "Export to .Net" umbraco DocumentTypes .
What i did...
static void Main(string[] args)
{
using (var dataProvider = new NodeDataProvider("umbraco.config", true))
using (var ctx = new CmsDataContext(dataProvider))
{
var latestPost = (from post in ctx.BlogPostDTs
orderby post.UpdateDate descending
select post).First();
}
}
===============
RECEIVING following ERROR. Please suggest what i am doing wrong???
===============
System.TypeInitializationException was unhandled
Message="The type initializer for 'umbraco.UmbracoSettings' threw an exception."
Source="businesslogic"
TypeName="umbraco.UmbracoSettings"
StackTrace:
at umbraco.UmbracoSettings.get_ForceSafeAliases()
at umbraco.cms.helpers.Casing.SafeAliasWithForcingCheck(String alias)
at umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml[T](XElement xml, T node)
at umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at EvaluateLinqToUmbracoConsoleApp.Program.Main(String[] args) in G:\Bharath\umbraco\EvaluateLinqToUmbracoConsoleApp\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ArgumentNullException
Message="Value cannot be null.\r\nParameter name: str"
Source="mscorlib"
ParamName="str"
StackTrace:
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()
InnerException:
LINQ to Umbraco doesn't work in a console application due to the way it needs to resolve the aliases of the nodes.
is working on a reply...