Hi guys, since a downloaded the latest DO version I have problems with the one Structure class I have.

Are there any changes that could have caused this? Example:

public class MyEntity: Entity
{
   [Field]
   public MyStructure MyStructureProperty {get; private set;}

   public MyEntity()
   {
      MyStructureProperty = new MyStructure("This is new"); 
      //Error occors right after the line above.
   }
}

public class MyStructure: Structure
{
   public MyStructure(string value)
   {
      Set(value);
      //So far so good, constructor does not fail...
   }
   [Field]
   [NotNullOrEmptyConstraint]
   public string Value { get; private set; }

   public void Set(string value)
   {
      Value = HashHelper.ApplySoopahDoopahHash(value ?? string.Empty);
   }
}

And the error is like this:

 System.ArgumentNullException: Value cannot be null.
    Parameter name: con
       at System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, ConstructorInfo con)
       at Xtensive.Reflection.DelegateHelper.CreateConstructorDelegate[TDelegate](Type type)
       at Xtensive.Threading.ThreadSafeDictionary`2.GetValue(TKey key, Func`2 generator)
       at Xtensive.Orm.Internals.Activator.CreateStructure(Type type, Persistent owner, FieldInfo field)
       at Xtensive.Orm.Internals.FieldAccessors.StructureFieldAccessor`1.<.cctor>b__0(Persistent obj, FieldInfo field)
       at Xtensive.Orm.Persistent.GetFieldValueAdapter(FieldInfo field, Func`3 ctor)
       at Xtensive.Orm.Internals.FieldAccessors.CachingFieldAccessor`1.GetValue(Persistent obj)
       at Xtensive.Orm.Internals.FieldAccessor`1.GetUntypedValue(Persistent obj)
       at Xtensive.Orm.Persistent.GetFieldValue(FieldInfo field)
       at Xtensive.Orm.Persistent.SetFieldValue(FieldInfo field, Object value, SyncContext syncContext, RemovalContext removalContext)
       at Xtensive.Orm.Persistent.SetFieldValue(FieldInfo field, Object value, SyncContext syncContext)
       at Xtensive.Orm.Persistent.SetFieldValue(FieldInfo field, Object value)
       at Xtensive.Orm.Persistent.SetFieldValue[T](FieldInfo field, T value)
       at Xtensive.Orm.Persistent.SetFieldValue[T](String fieldName, T value)
... in ...\MyEntity.cs:line xxx
    at MyEntity Constructor (Session session, ... string value) in ...\MyEntity.cs:line xxx
    at MyEntityService.SessionProvidingInvoker.PopulateData(Session session) in ...\MyEntityService\SessionProvidingInvoker.cs:line xxx

asked May 03 '12 at 11:45

Jos's gravatar image

Jos
44458

edited May 03 '12 at 12:16

Hello Jos, unfortunately I can't reproduce your problem. It seems that structure does not have required constructor. All required constructors are injected via PostSharp, so your assembly might be not processed by it. Please check that and if it does not work still try to make a sample project for us. You can contact me directly via e-mail support at dataobjects net

(May 04 '12 at 05:24) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Hi Denis, thanks for your quick response. Ok, I did have some Postsharp issues and also read about it in other issues in this forum. I did remove and reinstall DataObjects + PostSharp completely yesterday and also checked the attributes in the *.csproj files related to PostSharp. It all did not help. For now I will go trough this process again and double-check things and if that does not help I will let you know.

(May 04 '12 at 05:44) Jos Jos's gravatar image

One Answer:

Jos, you should not enable SkipPostSharp option (by either way - those are two equivalent) for DataObjects.Net to work. This option completely disables PostSharp processing of assembly. To add DataObjects.Net to your project you should import its .targets file

<Import Project="$(MSBuildExtensionsPath)\DataObjects.Net\v4.5\DataObjects.Net.targets" />

just after

 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Also you should add MSBuild property <DontImportPostSharp>. This property disables usage of installed PostSharp (if any), because DataObjects.Net has its own PostSharp.

Alternatively you can use ProjectTool that does that tasks for you.

answered May 04 '12 at 06:20

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

edited May 04 '12 at 06:21

Great, that was it, thanks!

(May 04 '12 at 07:42) Jos Jos'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

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×11
×1
×1

Asked: May 03 '12 at 11:45

Seen: 6,222 times

Last updated: May 04 '12 at 07:42

powered by OSQA