Dear xtensive,
all samples and unit tests are working well, but if i create a new project in Visual Studio 2008 i get troubles:
I have a quite simple model:
using Xtensive.Storage;
using Xtensive.Storage.Attributes;
using Xtensive.Storage.Configuration;
namespace DOTestApp
{
[HierarchyRoot(typeof(KeyGenerator), "ID", InheritanceSchema = InheritanceSchema.ClassTable)]
public class TestEntity : Entity
{
[Field]
public long ID { get; private set; }
}
}
And that is my test programm with the same app.config as WPF sample
using System;
using System.Reflection;
using Xtensive.Storage.Configuration;
using Xtensive.Storage;
using System.Diagnostics;
namespace DOTestApp
{
class Program
{
static void Main(string[] args)
{
// Creating the Domain
var dc = DomainConfiguration.Load("Default");
dc.Types.Register(Assembly.GetExecutingAssembly(), typeof(TestEntity).Namespace);
Domain domain = Domain.Build(dc);
using (domain.OpenSession())
{
using (Transaction.Open())
{
new TestEntity();
new TestEntity();
new TestEntity();
var test = new TestEntity();
Debug.Assert(test.ID == (long) test.Key.GetValue(0));
}
}
}
}
}
The assertion fails, the field ID is always 0. I think its a problem with PostSharp, but i don't know how to fix it.
If i modify the WPF sample and play around, everything is fine.
Can you provide a guide how to setup a new project?
Best regards Thomas
P.S.
this is the output of the build :
------ Neues Erstellen gestartet: Projekt: DOTestApp, Konfiguration: Debug Any CPU ------
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:POSTSHARP;DEBUG;TRACE /reference:..\Assemblies\log4net.dll /reference:..\Assemblies\nunit.framework.dll /reference:..\Assemblies\PostSharp.Laos.dll /reference:..\Assemblies\PostSharp.Public.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:..\Assemblies\Xtensive.Core.Aspects.dll /reference:..\Assemblies\Xtensive.Core.dll /reference:..\Assemblies\Xtensive.Core.Testing.dll /reference:..\Assemblies\Xtensive.Indexing.dll /reference:..\Assemblies\Xtensive.Integrity.dll /reference:..\Assemblies\Xtensive.PluginManager.dll /reference:..\Assemblies\Xtensive.Sql.Common.dll /reference:..\Assemblies\Xtensive.Sql.Common.MSSQL.dll /reference:..\Assemblies\Xtensive.Sql.Dom.dll /reference:..\Assemblies\Xtensive.Sql.Dom.MSSQL.dll /reference:..\Assemblies\Xtensive.Storage.dll /reference:..\Assemblies\Xtensive.Storage.Model.dll /reference:..\Assemblies\Xtensive.Storage.Providers.Index.dll /reference:..\Assemblies\Xtensive.Storage.Providers.Memory.dll /reference:..\Assemblies\Xtensive.Storage.Providers.MsSql.dll /reference:..\Assemblies\Xtensive.Storage.Providers.Sql.dll /reference:..\Assemblies\Xtensive.Storage.Rse.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\DOTestApp.exe /target:exe Program.cs Properties\AssemblyInfo.cs TestEntity.cs
Kompilierung abgeschlossen -- 0 Fehler, 0 Warnungen
"C:\Program Files (x86)\PostSharp 1.0\PostSharp.exe" "C:\Program Files (x86)\PostSharp 1.0\Default.psproj" "D:\CheckOutLibraries\DOTestApp\DOTestApp\obj\Debug\Before-PostSharp\DOTestApp.exe" "/P:Output=obj\Debug\DOTestApp.exe " "/P:ReferenceDirectory=D:\CheckOutLibraries\DOTestApp\DOTestApp " "/P:Configuration=Debug " "/P:Platform=AnyCPU " "/P:SearchPath=bin\Debug\,obj\Debug\, " "/P:IntermediateDirectory=obj\Debug\PostSharp " "/P:CleanIntermediate=False " "/P:MSBuildProjectFullPath=D:\CheckOutLibraries\DOTestApp\DOTestApp\DOTestApp.csproj " "/P:SignAssembly=False " "/P:PrivateKeyLocation= "
PostSharp 1.0 [1.0.11.424] - Copyright (c) Gael Fraiteur, 2005-2008.
info PS0035: C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe "D:\CheckOutLibraries\DOTestApp\DOTestApp\obj\Debug\PostSharp\DOTestApp.il" /QUIET /EXE /PDB "/RESOURCE=D:\CheckOutLibraries\DOTestApp\DOTestApp\obj\Debug\PostSharp\DOTestApp.res" "/OUTPUT=D:\CheckOutLibraries\DOTestApp\DOTestApp\obj\Debug\DOTestApp.exe" /SUBSYSTEM=3 /FLAGS=1 /BASE=10289152 /STACK=1048576 /ALIGNMENT=512 /MDV=v2.0.50727
DOTestApp -> D:\CheckOutLibraries\DOTestApp\DOTestApp\bin\Debug\DOTestApp.exe
========== Alles neu erstellen: 1 erfolgreich, Fehler bei 0, 0 ьbersprungen ==========
Updated at 29.10.2008 12:56:09
I found it myself:
this peace of code was missing in AssemblyInfo.cs
using Xtensive.Storage.Aspects;
// ...
[assembly: Persistent(AttributeTargetAssemblies = "DOTestApp")]
Important: You must provide the AssemblyName, not a namespace!
[assembly: Persistent(AttributeTargetAssemblies = "AssemblyName")]
Witch triggers the integration of the PostSharp cutpoints.
This thread was imported from our support forum. The original discussion may contain more detailed answer.
Original topic by MSE-iT.
asked
Oct 29 '08 at 12:30
Editor
46●156●156●157
Yes, we already decided to validate the proper application of this attribute during build stage - it's really not obvious why everything doesn't work as expected if it is applied improperly.