Hi
I've just started to use dataobjects.net framework, and can't run my first project.

I have database (MS SQL 2008) with 2 tables:

Blogs
BlogId (int, pk)
Name (varchar)

Posts
PostId (int, pk)
Title (varchar)
Content (varchar)
BlogId (int, fk, references Blogs.BlogId)

And data model with 2 classes:

  1. [HierarchyRoot]
  2. class Blog : Entity
  3. {
  4. [Field, Key]
  5. public int BlogId { get; private set; }
  6.  
  7. [Field]
  8. public string Name { get; set; }
  9.  
  10. [Field]
  11. public EntitySet<Post> Posts { get; set; }
  12. }
  13.  
  14. [HierarchyRoot]
  15. class Post : Entity
  16. {
  17. [Field, Key]
  18. public int PostId { get; private set; }
  19.  
  20. [Field]
  21. public string Title { get; set; }
  22.  
  23. [Field]
  24. public string Content { get; set; }
  25.  
  26. [Field]
  27. public Blog Blog { get; set; }
  28. }
In App.config file I have Default domain with 100% correct connection string:
<domain name="Default" upgradeMode="Validate" provider="sqlserver" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=TestEF;Integrated Security=True;">

In Program.cs file I load configuration and try to build domain

  1.             var config = DomainConfiguration.Load("Default");
  2.             var domain = Domain.Build(config);
but get exception on Domain.Build().

Access is denied: 'Xtensive.Orm.Internals.EntitySetItem`2[DBTest_DO.Model.Blog,DBTest_DO.Model.Post]'.

I tried to google it, or to find something like this here, in questions, but found nothing.
Thanks in advance!

UPD: Exception stack trace:

    System.TypeLoadException was unhandled
    Message=Access is denied: 'Xtensive.Orm.Internals.EntitySetItem2[DBTest_DO.Model.Blog,DBTest_DO.Model.Post]'</span>.
    Source=mscorlib
    TypeName=<span style="color:#666">""</span>
    StackTrace:
    at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
    at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
    at System.Reflection.Emit.TypeBuilder.CreateType()
    at Xtensive.Reflection.TypeHelper.CreateInheritedDummyType(String typeName, Type inheritFrom, <span style="color:#a535ae">Boolean</span> implementProtectedConstructorAccessor)
    at Xtensive.Orm.Building.Builders.ModelBuilder.&lt;BuildAuxiliaryTypes><span style="color:#21439c">b__1e</span>(String _underlyingTypeName, Type _genericInstanceType)
    at Xtensive.Collections.ThreadSafeDictionary2.GetValueT
    at Xtensive.Orm.Building.Builders.ModelBuilder.BuildAssociations()
    at Xtensive.Orm.Building.Builders.ModelBuilder.BuildModel()
    at Xtensive.Orm.Building.Builders.ModelBuilder.Run()
    at Xtensive.Orm.Building.Builders.ModelBuilder.Run(BuildingContext context)
    at Xtensive.Orm.Building.Builders.DomainBuilder.BuildModel()
    at Xtensive.Orm.Building.Builders.DomainBuilder.Run()
    at Xtensive.Orm.Building.Builders.DomainBuilder.Run(DomainBuilderConfiguration builderConfiguration)
    at Xtensive.Core.DelegateBindExtensions.<>cDisplayClass1`2.<Bind>b0()
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.BuildSingleStageDomain()
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Run()
    at Xtensive.Orm.Upgrade.UpgradingDomainBuilder.Build(DomainConfiguration configuration)
    at Xtensive.Orm.Domain.Build(DomainConfiguration configuration)
    at DBTest_DO.Program.Main(String[] args) in c:usersesindocumentsvisual studio 2010ProjectsDBTest_DODBTest_DOProgram.cs:line 16
    at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    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:

asked Feb 01 '13 at 10:30

esin's gravatar image

esin
9225

edited Feb 01 '13 at 12:10

Hello esin. Could you please provide a stack trace for the mentioned exception?

(Feb 01 '13 at 11:41) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Hello, Denis Sorry, totally forgot about that. Added it to question description

(Feb 01 '13 at 11:58) esin esin's gravatar image

One Answer:

To make this working you'll need to make your types public.

This is required because DataObjects.Net will need to instantiate internal generic types from some of you persistent types. For example it creates special internal typed called EntitySetItem<,> when you have one non-paired entity set or two paired entity sets.

Also it seems that you wanted to have paired association between posts and blogs:

[Field, Association(PairTo="Blog")]
public EntitySet<Post> Posts { get; set; }

answered Feb 01 '13 at 12:48

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

Thank you very much, Denis! That solved the problem

(Feb 01 '13 at 16:12) esin esin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA