I'm setting up a mapping between some nice, light weight POCOs and some big fat heavy data aware objects that are part of a legacy architecture.
The data objects are using SqlTypes for their properties - so I've got Data.Role.Name as SqlString but Poco.Role.Name as string.
Automapper is set up as such:
Mapper.CreateMap<Role, Data.Role>()
.ForMember(dest => dest.Role_ID,
opt => opt.MapFrom(src=>src.ID));
On the attempt to map Mapper.Map(pocoRole, dataRole), the exception (scroll down) is thrown.
How can I cause Automapper to map from string to sqlstring gracefully?
AutoMapper.AutoMapperMappingException : Trying to map Poco.Role to Data.Role.
Using mapping configuration for Poco.Role to Data.Role
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
----> AutoMapper.AutoMapperMappingException : Trying to map System.String to System.Data.SqlTypes.SqlString.
Using mapping configuration for Poco.Role to Data.Role
Destination property: Name
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
----> AutoMapper.AutoMapperMappingException : Trying to map System.String to System.Data.SqlTypes.SqlString.
Using mapping configuration for Poco.Role to Data.Role
Destination property: Name
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
----> AutoMapper.AutoMapperMappingException : Trying to map System.String to System.Data.SqlTypes.SqlString.
Using mapping configuration for Poco.Role to Data.Role
Destination property: Name
Missing type map configuration or unsupported mapping.
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
at AutoMapper.MappingEngine.Map(Object source, Object destination, Type sourceType, Type destinationType)
at AutoMapper.MappingEngine.Map(TSource source, TDestination destination)
at AutoMapper.Mapper.Map(TSource source, TDestination destination)
at Repository.RoleRepository.FindAll(IRole filter) in RoleRepository.cs: line 31
at Repository.ReaderRepositoryBase`1.Find(TEntity filter) in ReaderRepositoryBase.cs: line 30
at Test.RepositoryTests.GetRoleInternal() in RepositoryTests.cs: line 79
--AutoMapperMappingException
at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.MapPropertyValue(ResolutionContext context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap propertyMap)
at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.Map(ResolutionContext context, IMappingEngineRunner mapper)
at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context, IMappingEngineRunner mapper)
at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
--AutoMapperMappingException
at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
at AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.MapPropertyValue(ResolutionContext context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap propertyMap)
--AutoMapperMappingException
at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
I think you could use type converters for that. Look at this article:
http://automapper.codeplex.com/wikipage?title=Custom%20Type%20Converters
For that member, you should have to do something like:
.ForMember(d => d.Name, opt => opt.MapFrom(s => new SqlString(s.Name));
Or you could use the ContructUsing method.
Mapper.CreateMap<String, SqlString>().ConstructUsing(s => new SqlString(s));
Taking this approach will convert all String, SqlString pairs using the constructor so you don't need specific .ForMember maps.
Related
Iam using .NET 6 and TimeOnly? datatype in a C# model class. The database is MongoDB 4.4.
TimeOnly? (15:15 Hours) is saved into MongoDB as below.
"defaultTime" : {
"hour" : 15,
"minute" : 15,
"second" : 0,
"millisecond" : 0,
"ticks" : NumberLong(549000000000)
}
But when the data is read from MongoDB, Iam getting the following exception.
An unhandled exception has occurred while executing the request.
System.FormatException: An error occurred while deserializing the DefaultTime property of class Models.Customer: Value class System.TimeOnly cannot be deserialized.
---> MongoDB.Bson.BsonSerializationException: Value class System.TimeOnly cannot be deserialized.
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer`1 serializer, BsonDeserializationContext context)
at MongoDB.Bson.Serialization.Serializers.NullableSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeMemberValue(BsonDeserializationContext context, BsonMemberMap memberMap)
Any help on serialization and deserialization of TimeOnly datatype ?
Update:
I chose to save ticks in MongoDB to avoid the serialization & deserialization issues as below.
"defaultTime" : NumberLong(549000000000)
I'm following below example to create a class instance at runtime using autofac.
http://autofaccn.readthedocs.io/en/latest/advanced/delegate-factories.html
But when running locally, I'm seeing an exception. I'm very new to autofac and let me know if I'm doing anything wrong here or if you need any more information.
Code structure:
public class ClassName
{
public delegate ClassName Factory(Type1 obj1, string obj2);
public ClassName(Type1 obj1, string obj2)
{
this.type1 = obj1;
this.type2= obj2;
}
/*Some methods of this class that use type1 and type2*/
}
// Registration
container.RegisterType<Type1>();
container.RegisterType<ClassName.Factory>();
container.RegisterType<ClassName>().AsSelf().InstancePerDependency();
// In some method to create an instance of ClassName
var factory = container.Resolve<Factory>(); // This is throwing the following exception.
var instance = factory(obj1Instance, "text"); // obj1Instance and "text" parameters cannot be determined at registration time.
The exception stackTrace:
Logging handled exception: Autofac.Core.DependencyResolutionException: Autofac.Core.DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = Factory (ReflectionActivator), Services = [ClassName+Factory], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'ClassName+Factory' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.Object object' of constructor 'Void .ctor(System.Object, IntPtr)'. (See inner exception for details.) ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'ClassName+Factory' can be invoked with the available services and parameters:
Cannot resolve parameter 'System.Object object' of constructor 'Void .ctor(System.Object, IntPtr)'.
at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
--- End of inner exception stack trace ---
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context, IEnumerable`1 parameters)
The problem you have is that you're trying to register a factory.
Autofac understands how to resolve a delegate, but it doesn't understand how to register it.
This should work:
public class ClassName
{
public delegate ClassName Factory(Type1 obj1, string obj2);
public ClassName(Type1 obj1, string obj2)
{
this.type1 = obj1;
this.type2= obj2;
}
}
// Registration
container.RegisterType<ClassName>().AsSelf().InstancePerDependency();
// In some method to create an instance of ClassName
var factory = container.Resolve<ClassName.Factory>();
var instance = factory.Invoke(obj1Instance, "text");
Edit:
After running this myself I got the same exception but quickly realised what the issue was. Quoting autofac's entry on delegate factories I saw this:
By default, Autofac matches the parameters of the delegate to the parameters of the constructor by name
The names of my constructor's parameters and my delegates' parameters didn't match which leads autofac to try and resolve the object by type, and since you haven't (and shouldn't unless you know you want to, and even so, you shouldn't) registered a string autofac's Autofac.Core.Activators.Reflection.DefaultConstructorFinder fails.
Why I'm I getting this error on Employee Controller rest of them are working perfectly
Here is my Employee Controller
public class EmployeeController : ApiController
{
#region Call service
private readonly IEmployeeServices _employeeServices;
public EmployeeController(IEmployeeServices employeeServices)
{
_employeeServices = employeeServices;
}
readonly IEmployeeServices employeeServices = new EmployeeServices();
public EmployeeController():base()
{
_employeeServices = employeeServices;
}
}
AND this is my perfectly Working Product Controller
public class ProductController : ApiController
{
#region Call service
private readonly IProductServices _productServices;
public ProductController(IProductServices productServices)
{
_productServices = productServices;
}
readonly IProductServices productServices = new ProductServices();
public ProductController()
{
_productServices = productServices;
}
}
Here is the stack trace
An error has occurred.An error occurred when trying to create a controller of type 'EmployeeController'. Make sure that the controller has a parameterless public constructor.System.InvalidOperationException at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()An error has occurred.Resolution of the dependency failed, type = "TheWork.Controllers.EmployeeController", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, BusinessServices.IEmployeeServices, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving TheWork.Controllers.EmployeeController,(none)
Resolving parameter "employeeServices" of constructor TheWork.Controllers.EmployeeController(BusinessServices.IEmployeeServices employeeServices)
Resolving BusinessServices.IEmployeeServices,(none)
Microsoft.Practices.Unity.ResolutionFailedException at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve(IUnityContainer container, Type t, ResolverOverride[] overrides)
at Unity.WebApi.UnityDependencyScope.GetService(Type serviceType)
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func1& activator)
at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)An error has occurred.The current type, BusinessServices.IEmployeeServices, is an interface and cannot be constructed. Are you missing a type mapping?System.InvalidOperationException at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
at lambda_method(Closure , IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey)
at Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context)
at lambda_method(Closure , IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
Update
Here is the Unity Configuration
public static class UnityConfig
{
public static void RegisterComponents()
{
var container = new UnityContainer();
System.Web.Mvc.DependencyResolver.SetResolver(new UnityDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container);
RegisterTypes(container);
}
public static void RegisterTypes(IUnityContainer container)
{
ComponentLoader.LoadContainer(container, ".\\bin", "TheWork.dll");
ComponentLoader.LoadContainer(container, ".\\bin", "BusinessServices.dll");
ComponentLoader.LoadContainer(container, ".\\bin", "DataModel.dll");
}
}
Buried in the stack trace is the root cause of the issue:
InvalidOperationException - The current type,
BusinessServices.IEmployeeServices, is an interface and cannot be
constructed. Are you missing a type mapping?
----------------------------------------------- At the time of the exception, the container was: Resolving
TheWork.Controllers.EmployeeController,(none) Resolving parameter
"employeeServices" of constructor
TheWork.Controllers.EmployeeController(BusinessServices.IEmployeeServices
employeeServices) Resolving BusinessServices.IEmployeeServices,(none)
Microsoft.Practices.Unity.ResolutionFailedException at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
existing, String name, IEnumerable1 resolverOverrides)
The issue is that the EmployeeController requires an instance of IEmployeeServices but Unity does not know what concrete type to instantiate. It looks like the implementation class is supposed to be registered by the call to ComponentLoader.LoadContainer(container, ".\\bin", "BusinessServices.dll"); but for some reason it is not being registered. It could be a bug in that code or perhaps the BusinessServices.dll is out of date and does not contain the IEmployeeServices definition.
It's hard to tell why IEmployeeServices is not registered without seeing all the code and runtime dependencies (because types are being dynamically loaded/registered).
Try this way :)
/// Load your modules or register your services here!
/// </summary>
/// <param name="kernel">The kernel.</param>
private static void RegisterServices(IKernel kernel)
{
kernel.Bind<IEmployeeServices >().To<EmployeeServices >().InRequestScope();
}
I am using ServiceStack in standalone mode. It is now giving a TypeInitialzationException when executing Apphost.Start().
At the time, I was working on implementing some custom filters, but removing the annotation from the only filtered DTO class did not solve the problem.
The stack trace does not show any of my classes involved, and the failing class is the JsvReader which I don't use explicitly.
How can prevent this problem?
Note: I just used nuget to update all packages, so this is current as of now, 3.9.43 for all ServiceStack components.
Exception Detail
System.TypeInitializationException occurred
HResult=-2146233036
Message=The type initializer for 'ServiceStack.Text.Jsv.JsvReader`1' threw an exception.
Source=ServiceStack.Text
TypeName=ServiceStack.Text.Jsv.JsvReader`1
StackTrace:
at ServiceStack.Text.Jsv.JsvReader`1.GetParseFn()
at ServiceStack.Text.Jsv.JsvReader.GetParseFn(Type type)
at ServiceStack.ServiceModel.Serialization.StringMapTypeDeserializer..ctor(Type type)
at ServiceStack.ServiceHost.RestPath..ctor(Type requestType, String path, String verbs, String summary, String notes)
at ServiceStack.ServiceHost.ServiceController.RegisterRestPaths(Type requestType)
at ServiceStack.ServiceHost.ServiceController.RegisterCommon(Type serviceType, Type requestType, Type responseType)
at ServiceStack.ServiceHost.ServiceController.RegisterNService(ITypeFactory serviceFactoryFn, Type serviceType)
at ServiceStack.ServiceHost.ServiceController.Register(ITypeFactory serviceFactoryFn)
at ServiceStack.ServiceHost.ServiceManager.Init()
at ServiceStack.WebHost.Endpoints.Support.HttpListenerBase.Init()
at ArdWebServer.Program.Main(String[] args)
InnerException: System.TypeInitializationException
HResult=-2146233036
Message=The type initializer for 'ServiceStack.Text.Common.DeserializeSpecializedCollections`2' threw an exception.
Source=ServiceStack.Text
TypeName=ServiceStack.Text.Common.DeserializeSpecializedCollections`2
StackTrace:
at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.get_Parse()
at ServiceStack.Text.Common.JsReader`1.GetCoreParseFn[T]()
at ServiceStack.Text.Common.JsReader`1.GetParseFn[T]()
at ServiceStack.Text.Jsv.JsvReader`1..cctor()
InnerException: System.NullReferenceException
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=ServiceStack.Text
StackTrace:
at ServiceStack.Text.PlatformExtensions.GenericTypeArguments(Type type)
at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.GetGenericEnumerableParseFn()
at ServiceStack.Text.Common.DeserializeSpecializedCollections`2.GetParseFn()
at ServiceStack.Text.Common.DeserializeSpecializedCollections`2..cctor()
InnerException:
My App host
public class AppHost : AppHostHttpListenerBase
{
public AppHost() : base("IAM Tools Service Stack Host", typeof (Tims.Global).Assembly)
{
CatchAllHandlers.Add(
(httpMethod, pathInfo, filePath) =>
Tims.Support.StaticFileHandler.Factory(
Params.Instance.HttpDataDir,
"/",
pathInfo
)
);
}
public override void Configure(Funq.Container container)
{
SetConfig(new EndpointHostConfig()
{
DebugMode = true,
WriteErrorsToResponse = true
});
}
}
I have run into a very weird issue. I have several working Fitnesse tests which insert data in a database, then test my full MVC application stack.
When I try to add 2 Component property mappings to my entity map, I get an error saying "Unable to find assembly 'FluentNHibernate ...' which seems somewhat cryptic.
All of this is being run through Fitnesse, so this could be an issue with how Fitnesse loads dependencies... I have no idea of knowing for sure though. The only thing I know is that this code runs fine until I add the 2 "Component" mappings. On top of that, those mappings run fine when this code is run through the normal web application (so I know the "Component" mapping and SessionFactory class works outside of Tests project).
Does anyone have any ideas why I would get the error message I'm getting? Please let me know if there is any other code I need to post. Any help is greatly appreciated!
DLL Versions:
NHibernate - 3.3.1.4000
FluentNHibernate - 1.3.0.733
Fitnesse - v20111026
fitSharp - 2.2.4498.25493
Here is my entity:
// namespace Reporting.Domain
public class Holdings
{
public virtual int HoldingsId { get; set; }
public virtual DateTime AsOfDate { get; set; }
public virtual string Portfolio { get; set; }
// need to add these next 2 properties!
public virtual Balances PriorPeriod { get; set; }
public virtual Balances CurrentPeriod { get; set; }
}
my mapping file:
// namespace Reporting.Infrastructure
public sealed class HoldingsMap : ClassMap<Holdings>
{
public HoldingsMap()
{
Id(x => x.HoldingsId).GeneratedBy.Identity();
Map(x => x.AsOfDate).Not.Nullable();
Map(x => x.Portfolio).Not.Nullable();
// adding these lines eventually leads to the error
Component(x=> x.PriorPeriod).ColumnPrefix("Prior");
Component(x=> x.CurrentPeriod).ColumnPrefix("Current");
}
}
my SessionFactory (the error happens when BuildSessionFactory is called):
// namespace Reporting.Infrastructure
public class SessionFactory
{
public ISessionFactory CreateSession(Action<Configuration> configurationFunction)
{
return CreateConfiguration().ExposeConfiguration(c => {}).BuildSessionFactory();
}
private FluentConfiguration CreateConfiguration()
{
var connectionString = "...";
var msSqlConfiguration = MsSqlConfiguration.MsSql2008.ConnectionString(connectionString);
var database = Fluently.Configure().Database(msSqlConfiguration);
return database.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SessionFactory>().Conventions.Add(ForeignKey.EndsWith("Id")));
}
}
I get this stack trace:
__EXCEPTION__:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> System.Runtime.Serialization.SerializationException: Unable to find assembly 'FluentNHibernate, Version=1.3.0.733, Culture=neutral, PublicKeyToken=8aa435e3cb308880'.
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at FluentNHibernate.Utils.Extensions.DeepClone[T](T obj)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentNHibernate.Visitors.ComponentReferenceResolutionVisitor.ProcessComponent(ReferenceComponentMapping mapping)
at FluentNHibernate.MappingModel.ClassBased.ReferenceComponentMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.MappedMembers.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.HibernateMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.Utils.CollectionExtensions.Each[T](IEnumerable`1 enumerable, Action`1 each)
at FluentNHibernate.PersistenceModel.ApplyVisitors(IEnumerable`1 mappings)
at FluentNHibernate.PersistenceModel.BuildMappings()
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at Reporting.Infrastructure.SessionFactory.CreateSession() in Reporting.Infrastructure\SessionFactory.cs:line 32
at Reporting.FitnesseTests.Database.Setup() in Reporting.FitnesseTests\Database.cs:line 23
--- End of inner exception stack trace ---
at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid()
at fitSharp.Slim.Operators.ExecuteCall.ExecuteOperation(Tree`1 parameters)
at fitSharp.Slim.Operators.InvokeInstructionBase.Invoke(TypedValue instance, MemberName memberName, Tree`1 parameters)
FWIW, this is how I use the session factory from my Fitnesse Tests project:
// namespace Reporting.FitnesseTests
public class Database
{
public static ISession Session { get; private set; }
public static void Setup()
{
Session = new SessionFactory().CreateSession().OpenSession();
}
}
and my Fitnesse Classpath is:
!path ..\Reporting.FitnesseTests\bin\Debug\Reporting.FitnesseTests.dll
Try putting the DLLs that the test is looking for in the same folder as the fitsharp Runner.exe. One problem that I ran into is that .NET run-time dependencies that are defined in app.config are resolved from the directory in which the process is executed from which in this case is probably the directory where fitsharp resides. There is a apparently a way to use the fitsharp suite configuration file to change this behavior but I haven't been able to get it working successfully (http://fitsharp.github.com/FitSharp/SuiteConfigurationFile.html).