I'm doing unit test(using NUnit) on Postgresql, unfortunately it causes an error:
Internal error
RemotingException: Unix transport error.
Note: The error doesn't happen if I'm using Sqlite
Code:
using System;
using ncfg = NHibernate.Cfg;
using System.Collections.Generic;
using System.Reflection;
using NHibernate;
using System.Data;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Dialect;
using NHibernate.Driver;
using NHibernate.ByteCode.LinFu;
using NUnit.Framework;
using NHibernate.Mapping;
namespace RuntimeNhibernate
{
class MainClass
{
public static void Main (string[] args)
{
using(var c = new BlogTestFixture())
{
c.CanSaveAndLoadBlog();
}
}
}
public class InMemoryDatabaseTest : IDisposable
{
private static ncfg.Configuration Configuration;
private static ISessionFactory SessionFactory;
protected ISession session;
public InMemoryDatabaseTest(Assembly assemblyContainingMapping)
{
if (Configuration == null)
{
Configuration = new ncfg.Configuration()
.SetProperty(ncfg.Environment.ReleaseConnections,"on_close")
.SetProperty(ncfg.Environment.Dialect, typeof (SQLiteDialect).AssemblyQualifiedName)
.SetProperty(ncfg.Environment.ConnectionDriver, typeof(SQLite20Driver).AssemblyQualifiedName)
.SetProperty(ncfg.Environment.ConnectionString, "data source=:memory:")
.SetProperty(ncfg.Environment.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName)
.AddAssembly(assemblyContainingMapping);
/*Configuration = new ncfg.Configuration()
.SetProperty(ncfg.Environment.ReleaseConnections,"on_close")
.SetProperty(ncfg.Environment.Dialect, typeof (PostgreSQLDialect).AssemblyQualifiedName)
.SetProperty(ncfg.Environment.ConnectionDriver, typeof(NpgsqlDriver).AssemblyQualifiedName)
.SetProperty(ncfg.Environment.ConnectionString, "Server=127.0.0.1;Database=memdb;User ID=postgres;Password=password;Pooling=false;")
.SetProperty(ncfg.Environment.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName)
.AddAssembly(assemblyContainingMapping);*/
SessionFactory = Configuration.BuildSessionFactory();
}
session = SessionFactory.OpenSession();
new SchemaExport(Configuration).Execute(true, true, false, session.Connection, Console.Out);
}
public void Dispose()
{
session.Dispose();
}
}//class InMemory
public class Blog
{
public virtual int BlogId { get; set; }
public virtual bool AllowsComments { set; get; }
public virtual DateTime CreatedAt { get; set; }
public virtual string Subtitle { get; set; }
public virtual string Title { get; set; }
}
[TestFixture]
public class BlogTestFixture : InMemoryDatabaseTest
{
public BlogTestFixture() : base(typeof(Blog).Assembly)
{
}
[Test]
public void IsOK()
{
Assert.AreEqual(true, true);
return;
}
[Test]
public void CanSaveAndLoadBlog()
{
object id;
using (var tx = session.BeginTransaction())
{
id = session.Save(new Blog
{
AllowsComments = true,
CreatedAt = new DateTime(2000,1,1),
Subtitle = "Hello",
Title = "World",
});
tx.Commit();
}
session.Clear();
Console.WriteLine("Hello {0}", id);
using (var tx = session.BeginTransaction())
{
var blog = session.Get<Blog>(id);
Assert.AreEqual(new DateTime(2000, 1, 1), blog.CreatedAt);
Assert.AreEqual("Hello", blog.Subtitle);
Assert.AreEqual("World", blog.Title);
Assert.AreEqual(true, blog.AllowsComments);
tx.Commit();
}
}
}//Test
}//namespace
What could be the possible reason when I unit test Postgresql, it results to RemotingException: Unix transport error. ?
If I run the code outside of unit test (e.g. Main), it works. Btw, if I unit test Sqlite, it doesn't cause any errors too
Found the answer, I tried launching MonoDevelop from Terminal (/Applications/MonoDevelop.app/Contents/MacOS/monodevelop), I saw the more detailed error from the commandline when I ran the unit tests.
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for Npgsql.NpgsqlConnection ---> System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'Npgsql'.
at (wrapper managed-to-native) System.MonoCustomAttrs:GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool)
at System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) [0x00000] in <filename unknown>:0
at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at System.Reflection.Assembly.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
at System.Resources.ResourceManager.GetNeutralResourcesLanguage (System.Reflection.Assembly a) [0x00000] in <filename unknown>:0
at System.Resources.ResourceManager..ctor (System.Type resourceSource) [0x00000] in <filename unknown>:0
at Npgsql.NpgsqlConnection..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod*,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
Then I tried changing the Npgsql version(the one that causes an error came from http://pgfoundry.org/frs/download.php/2868/Npgsql2.0.11-bin-ms.net4.0.zip) to http://pgfoundry.org/frs/download.php/2860/Npgsql2.0.11-bin-mono2.0.zip After this, there's no more Unix transport error ^_^
Lesson learned, use the Mono version of the component you are using if you are running things on Mono
This exception occurs, when a unit test in MonoDevelop raises an exception, which could not be caught by the test runner (i.e. when the test starts some threads and they crash).
If you have such a test which is grey even after running
and the unit test pad shows the internal error
you should try running the test on your console with nunit-console (should be in the repo of your distro where mono comes from) and leak the exception.
In my case it was a simple multiple enumeration exception in a sub-thread of my test.
Unhandled exceptions:
1) Residata.Platform.Server.Message.Test.MemoryBrokerTest.AssertThatReceiveMethodWaitsUntilPublish : System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.Collections.Generic.List`1+Enumerator[Residata.Platform.Contract.Message.IPackage].MoveNext () [0x00000] in <filename unknown>:0
Related
I have developed an WCF Service Library that uses Agatha RRSL, but I can not figure out how to initialize the container. If I recreate this service in an ASP.NET Web Application, I can call the initialization code from the Global.asax.cs Application_Start() and everything works perfectly. The initialization code is:
public static class ComponentRegistration
{
public static void Register()
{
new ServiceLayerConfiguration(Assembly.GetExecutingAssembly(),
typeof(HelloWorldRequest).Assembly,
typeof(Agatha.Castle.Container)).Initialize();
}
}
In the WCF Service Library, I added an App_Code folder with a class that calls:
public static void AppInitialize()
{
ComponentRegistration.Register();
}
That didn't work as my client app throws an exception that there is no response with that type. I also tried adding a component to the web.config file, but I never got that even close to working.
I also tried to create a custom ServiceHost that does the initialization:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using Agatha.ServiceLayer;
using System.Reflection;
using Sample.Common.RequestsAndResponses;
namespace Sample.ServiceLayer.WCFHost
{
public class CustomServiceHostFactory : ServiceHostFactory
{
public CustomServiceHostFactory()
{
new ServiceLayerConfiguration(Assembly.GetExecutingAssembly(), typeof(HelloWorldRequest).Assembly,
typeof(Agatha.Castle.Container)).Initialize();
}
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
return new CustomServiceHost(serviceType, baseAddresses);
}
}
public class CustomServiceHost : ServiceHost
{
public CustomServiceHost()
{
}
public CustomServiceHost(Type serviceType, params Uri[] baseAddresses)
: base(serviceType, baseAddresses)
{
}
protected override void OnOpening()
{
base.OnOpening();
}
protected override void OnClosing()
{
base.OnClosing();
}
protected override void ApplyConfiguration()
{
base.ApplyConfiguration();
}
}
}
However, I get the same exception on my client:
System.InvalidOperationException was unhandled
Message=There is no response with type Sample.Common.RequestsAndResponses.HelloWorldResponse. Maybe you called Clear before or forgot to add appropriate request first.
Source=Agatha.Common
StackTrace:
at Agatha.Common.RequestDispatcher.Get[TResponse]() in c:\src\Agatha\Agatha.Common\RequestDispatcher.cs:line 125
at Agatha.Common.RequestDispatcher.Get[TResponse](Request request) in c:\src\Agatha\Agatha.Common\RequestDispatcher.cs:line 150
at ConsoleApplication1.Program.Main(String[] args) in C:\Users\ultraviolet\Documents\Visual Studio 2010\Projects\AgathaHelloWorld\ConsoleApplication1\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
What approach should I take to get the WCF Service Library to run my initialization code so that the host returns the correct type?
Any guidance would be much appreciated.
Thanks.
there
Runtime Context: I write a simple WCF console application by VS2012,running smoothly on Windows, but exception happened when try to run it on Ubuntu by mono
Mono Version: 2.10.6
Exception:
Unhandled Exception: System.InvalidOperationException: None of the listener channel types is supported
at System.ServiceModel.ServiceHostBase.BuildListener (System.ServiceModel.Description.ServiceEndpoint se, System.ServiceModel.Channels.BindingParameterCollection pl) [0x00000] in :0
at System.ServiceModel.ServiceHostBase.BuildChannelDispatcher (System.ServiceModel.Description.ServiceEndpoint se, System.ServiceModel.Channels.BindingParameterCollection commonParams) [0x00000] in :0
at System.ServiceModel.ServiceHostBase.InitializeRuntime () [0x00000] in :0
at System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan timeout) [0x00000] in :0
at System.ServiceModel.Channels.CommunicationObject.Open (TimeSpan timeout) [0x00000] in :0
at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in :0
at DynIPServiceHost.Program.Main (System.String[] args) [0x00000] in :0
The Only Main function is :
static void Main(string[] args)
{
try
{
Binding binding = new NetTcpBinding();
ServiceHost sh = new ServiceHost(typeof(DynIPService.DynIPService));
sh.AddServiceEndpoint("DynIPServiceContract.IDynIPService", binding, "net.tcp://10.161.66.213:808");
sh.Open();
foreach (var ep in sh.Description.Endpoints)
{
Console.WriteLine("Address: {0}, ListenUri: {1}, ListenUriMode: {2} ", ep.Address, ep.ListenUri, ep.ListenUriMode);
}
Console.WriteLine("Service is running");
//Console.WriteLine("Current Uri is:);
}
catch (Exception ex)
{
Console.WriteLine("Error:" + ex.Message);
throw;
}
finally
{
Console.ReadKey();
}
}
}
I'm trying to attempt a structure with Autofac on Wcf.
namespace WcfService1.Model
{
[DataContract(IsReference = true)]
public partial class Account
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Surname { get; set; }
[DataMember]
public string Email { get; set; }
[DataMember]
public Nullable<System.DateTime> CreateDate { get; set; }
}
}
Model>IAccounRepository.cs
1.
namespace WcfService1.Model
{
public interface IAccountRepository
{
IEnumerable<Account> GetAllRows();
bool AddAccount(Account item);
}
}
Model>AccounRepository.cs
2.
namespace WcfService1.Model
{
public class AccountRepository:IAccountRepository
{
private Database1Entities _context;
public AccountRepository()
{
if(_context == null)
_context =new Database1Entities();
}
public IEnumerable<Account> GetAllRows()
{
if (_context == null)
_context = new Database1Entities();
return _context.Account.AsEnumerable();
}
public bool AddAccount(Account item)
{
try
{
if (_context == null)
_context = new Database1Entities();
_context.Entry(item).State = EntityState.Added;
_context.Account.Add(item);
_context.SaveChanges();
return true;
}
catch (Exception ex)
{
var str = ex.Message;
return false;
}
}
}
}
DbConnection > EntityFramework + DbContext
IService1.cs
Code:
namespace WcfService1
{
[ServiceContract(SessionMode = SessionMode.Allowed)]
public interface IService1
{
[OperationContract]
IList<Account> GetAccounts();
[OperationContract]
bool AddAccount(Account item);
}
}
Service1.cs
Code:
namespace WcfService1
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1:IService1
{
private readonly IAccountRepository _repository;
public Service1(IAccountRepository repository)
{
_repository = repository;
}
public IList<Account> GetAccounts()
{
var items = _repository.GetAllRows().ToList();
return items;
}
public bool AddAccount(Account item)
{
item.CreateDate = DateTime.Now;
return _repository.AddAccount(item);
}
}
}
Service1.svc
Code:
<%# ServiceHost Language="C#"
Debug="true"
Service="WcfService1.Service1, WcfService1"
Factory="Autofac.Integration.Wcf.AutofacWebServiceHostFactory, Autofac.Integration.Wcf" %>
Global.asax.cs
Code:
protected void Application_Start(object sender, EventArgs e)
{
var builder = new ContainerBuilder();
builder.RegisterType< AccountRepository>().As< IAccountRepository>();
builder.RegisterType< Service1 >().As< IService1>();
AutofacHostFactory.Container = builder.Build();
}
I'm getting the following error, could not find a solution. What's my wrong.
Error Message :
Server Error in '/' Application.
The service 'WcfService1.Service1, WcfService1' configured for WCF is not registered with the Autofac container.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The service 'WcfService1.Service1, WcfService1' configured for WCF is not registered with the Autofac container.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The service 'WcfService1.Service1, WcfService1' configured for WCF is not registered with the Autofac container.]
Autofac.Integration.Wcf.AutofacHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +667
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +2943
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +88
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1239
[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: The service 'WcfService1.Service1, WcfService1' configured for WCF is not registered with the Autofac container..]
System.Runtime.AsyncResult.End(IAsyncResult result) +454
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +413
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +327
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext, Boolean ensureWFService) +46
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +384
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +238
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +114
In addition to the other answers, you should make sure you're using the fully-qualified service name in the Service attribute of the ServiceHost element in your .svc file.
For example, instead of:
<%# ServiceHost Language="C#" Debug="true" Service="MoviesService.MoviesService" CodeBehind="MoviesService.svc.cs" %>
Use:
<%# ServiceHost Language="C#" Debug="true" Service="MoviesService.MoviesService, MoviesService" CodeBehind="MoviesService.svc.cs" %>
Source: http://jmonkee.net/wordpress/2011/09/05/autofac-wcfintegration-service-not-registered-with-the-autofac-container/
You should register the service as self, not as the interface.
builder.RegisterType< Service1 >().AsSelf();
Just Register the Service1 Like this builder.RegisterType<Service1>(); instead builder.RegisterType<Service1>().As<IService1>();
You should write in .svc file (Namespace1):
<%# ServiceHost Language="C#" Debug="true" Service="Namespace1.Service1, Namespace1"
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" CodeBehind="Service1.svc.cs" %>
Give this a try:
var builder = new ContainerBuilder();
builder.Register(c => new AccountRepository()).As<IAccountRepository>();
builder.Register(c => new Service1(c.Resolve<IAccountRepository>())).AsSelf();
AutofacHostFactory.Container = builder.Build();
You should not use.
`builder.RegisterType< Service1 >().As'
but use RegisterType without extension methods
'builder.RegisterType();'
For me I was using a Project called 'WCF Service'
This by default gave me a name space called WCF_Service, and a assembly name of 'WCF Service'
None of the fixes worked until that space was removed.
I have created NUnit suite that initialises Chrome Webdriver in Selenium. This works fine with InternetExplorer driver and Firefox driver however fails with SerializationException every time I try to run it with Chrome driver.
Anyone can point me in right direction?
namespace TestNamespace
{
using System;
using NUnit.Framework;
using NUnit.Core;
using SeleniumTests;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
class AllInOne
{
public static IWebDriver WebDriver { get; private set; }
[Suite]
public static TestSuite Suite
{
get
{
TestSuite suite = new TestSuite("All Tests");
SetupChrome();
suite.Add(new FlashLoadedTest { Driver = WebDriver });
return suite;
}
}
private static void SetupChrome()
{
WebDriver = new ChromeDriver(#"C:\Users\<username>\AppData\Local\Google\Chrome\Application");
}
}
}
This is error I get:
Unhandled Exception:
System.Runtime.Serialization.SerializationException: Unable to find assembly 'WebDriver, Version=2.15.0.0, Culture=neutral, PublicKeyToken=1c2bd1631853048f'.
Server stack trace:
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.ObjectMap.Create(String name, 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.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
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.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeMessageParts(MemoryStream stm)
at System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.FixupForNewAppDomain()
at System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Util.TestDomain.Load(TestPackage package)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
I am not into NUnit, but I believe that IWebDriver class is for Internet Explorer only - but that applies to Java
Do you have class WebDriver also? If yes, try using it.
I'm using Sharp Architecture 1.6 VS2010 and investigating using GUIDs
but I'm encountering an error that I've been unable to resolve.
Person Entity
using System;
using NHibernate.Validator.Constraints;
using SharpArch.Core.DomainModel;
namespace SharpDemo.Core
{
public class Person : EntityWithTypedId<Guid>
{
[NotNullNotEmpty(Message = "First name must be provided.")]
public virtual string FirstName { get; set; }
[NotNullNotEmpty(Message = "Last name must be provided.")]
public virtual string LastName { get; set; }
}
}
Fluent Mapping
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using SharpDemo.Core;
namespace SharpDemo.Data.NHibernateMaps
{
public class PersonMap : IAutoMappingOverride<Person>
{
public void Override(AutoMapping<Person> mapping)
{
mapping.Schema("dbo");
mapping.Table("People");
mapping.Id(x => x.Id).GeneratedBy.GuidComb();
}
}
}
The solution successfully builds but encounters the below error when
debugging (which I have been unable to resolve). Any assistance is
appreciated.
Source Error
Line 83: private void InitializeNHibernateSession()
Line 84: {
Line 85: NHibernateSession.Init(
Line 86: webSessionStorage,
Line 87: new string[] { Server.MapPath("~/bin/SharpDemo.Data.dll") },
Stack Trace
[FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).]
System.Guid..ctor(String g) +2486
NHibernate.Type.GuidType.FromStringValue(String xml) +75
NHibernate.Type.GuidType.StringToObject(String xml) +86
NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor) +644
[MappingException: Could not parse identifier unsaved-value: 0]
NHibernate.Engine.UnsavedValueFactory.GetUnsavedIdentifierValue(String unsavedValue, IGetter identifierGetter, IType identifierType, ConstructorInfo constructor) +872
NHibernate.Tuple.PropertyFactory.BuildIdentifierProperty(PersistentClass mappedEntity, IIdentifierGenerator generator) +220
NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory) +696
NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) +784
NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping) +379
NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg) +182
NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) +2117
NHibernate.Cfg.Configuration.BuildSessionFactory() +189
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +76
[FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
* Database was not configured through Database method.
]
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() +120
SharpArch.Data.NHibernate.NHibernateSession.CreateSessionFactoryFor(String[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel, Configuration cfg, IPersistenceConfigurer persistenceConfigurer) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:328
SharpArch.Data.NHibernate.NHibernateSession.AddConfiguration(String factoryKey, String[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel, Configuration cfg, String validatorCfgFile, IPersistenceConfigurer persistenceConfigurer) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:138
SharpArch.Data.NHibernate.NHibernateSession.AddConfiguration(String factoryKey, String[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel, String cfgFile, IDictionary`2 cfgProperties, String validatorCfgFile, IPersistenceConfigurer persistenceConfigurer) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:126
SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage storage, String[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel, String cfgFile, IDictionary`2 cfgProperties, String validatorCfgFile, IPersistenceConfigurer persistenceConfigurer) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:101
SharpArch.Data.NHibernate.NHibernateSession.Init(ISessionStorage storage, String[] mappingAssemblies, AutoPersistenceModel autoPersistenceModel, String cfgFile) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:51
SharpDemo.Web.MvcApplication.InitializeNHibernateSession() in D:\Web\Mvc\Projects\Temp\SharpDemo\app\SharpDemo.Web\Global.asax.cs:85
SharpDemo.Web.MvcApplication.<Application_BeginRequest>b__3() in D:\Web\Mvc\Projects\Temp\SharpDemo\app\SharpDemo.Web\Global.asax.cs:76
SharpArch.Data.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod) in e:\WorkSpaces\Git\SharpArchitecture\Trunk\src\SharpArch\SharpArch.Data\NHibernate\NHibernateInitializer.cs:46
SharpDemo.Web.MvcApplication.Application_BeginRequest(Object sender, EventArgs e) in D:\Web\Mvc\Projects\Temp\SharpDemo\app\SharpDemo.Web\Global.asax.cs:75
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
It looks like the unsaved value is being set to 0 by the automapping. Try changing your mapping override to:
mapping.Id(x => x.Id).GeneratedBy.GuidComb().Default(Guid.Empty);
mapping.Id(x => x.Id).GeneratedBy.GuidComb().UnsavedValue(Guid.Empty);