Copied to clipboard

Flag this post as spam?

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


  • Bharath 40 posts 62 karma points
    Sep 18, 2010 @ 10:58
    Bharath
    0

    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: 

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 18, 2010 @ 13:05
    Aaron Powell
    0

    LINQ to Umbraco doesn't work in a console application due to the way it needs to resolve the aliases of the nodes.

Please Sign in or register to post replies

Write your reply to:

Draft