Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6085491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:38:41+00:00 2026-05-23T11:38:41+00:00

I am just trying to test some validation which involves the database. The setup

  • 0

I am just trying to test some validation which involves the database. The setup of my test code looks something like this:

[TestFixture]
public class UserValidatorTester : RepositoryTestsBase
{
    [SetUp]
    public void Setup()
    {
        ServiceLocatorInitializer.Init();
        base.SetUp(); 
    }


...

The ServiceLocatorInitializer looks like this:

    public class ServiceLocatorInitializer
        {
            public static void Init() 
            {
                IWindsorContainer container = new WindsorContainer();

                container.Register(
                        Component
                            .For(typeof(IEntityDuplicateChecker))
                            .ImplementedBy(typeof(EntityDuplicateChecker))
                            .Named("entityDuplicateChecker"));

container.Register(Component.For(typeof(ISessionFactoryKeyProvider)).ImplementedBy(typeof(DefaultSessionFactoryKeyProvider)).Named("sessionFactoryKeyProvider"));


                ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
            }
        }

I am getting:

at SharpArch.Domain.SafeServiceLocator`1.GetService()

at SharpArch.NHibernate.SessionFactoryKeyHelper.GetKeyFrom(Object anObject)
at SharpArch.NHibernate.NHibernateRepositoryWithTypedId2.get_Session()
at EID2.Tasks.Repositories.UserRepository.SaveOrUpdate(User entity) in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tasks\Repositories\UserRepository.cs:line 17
at EID2.Tasks.UserTasks.CreateUser(CreateUserViewModel CreateUserViewModel) in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tasks\UserTasks.cs:line 33
at EID2.Tests.Validation.UserValidatorTester.LoadTestData() in C:\Users\csetzkorn\Documents\Visual Studio 2010\Projects\EID2\Solutions\EID2.Tests\Validation\UserValidatorTester.cs:line 39
at SharpArch.Testing.NUnit.NHibernate.RepositoryTestsBase.SetUp()
--NullReferenceException
at Microsoft.Practices.ServiceLocation.ServiceLocator.get_Current()
at SharpArch.Domain.SafeServiceLocator
1.GetService()

Christian

PS:

Included dlls:

<ItemGroup>
    <Reference Include="Castle.Core">
      <HintPath>..\..\Packages\Castle.Core.2.5.2\lib\SL4\Castle.Core.dll</HintPath>
    </Reference>
    <Reference Include="Castle.Windsor">
      <HintPath>..\..\Packages\Castle.Windsor.2.5.3\lib\NET40\Castle.Windsor.dll</HintPath>
    </Reference>
    <Reference Include="CommonServiceLocator.WindsorAdapter">
      <HintPath>..\..\Packages\CommonServiceLocator.WindsorAdapter.1.0\lib\NET35\CommonServiceLocator.WindsorAdapter.dll</HintPath>
    </Reference>
    <Reference Include="EID2.Tasks">
      <HintPath>..\xxx.Tasks\bin\Debug\xxx.Tasks.dll</HintPath>
    </Reference>
    <Reference Include="FluentValidation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a82054b837897c66, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\Packages\FluentValidation\FluentValidation.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.Practices.ServiceLocation">
      <HintPath>..\..\Packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
    </Reference>
    <Reference Include="MvcContrib.TestHelper">
      <HintPath>..\..\Packages\MvcContrib.Mvc3-ci.3.0.68.0\lib\MvcContrib.TestHelper.dll</HintPath>
    </Reference>
    <Reference Include="NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.dll</HintPath>
    </Reference>
    <Reference Include="NHibernate.ByteCode.Castle">
      <HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.ByteCode.Castle.dll</HintPath>
    </Reference>
    <Reference Include="NHibernate.Validator">
      <HintPath>..\..\ReferencedAssemblies\NHibernate\NHibernate.Validator.dll</HintPath>
    </Reference>
    <Reference Include="nunit.framework">
      <HintPath>..\..\Packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath>
    </Reference>
    <Reference Include="Rhino.Mocks">
      <HintPath>..\..\ReferencedAssemblies\RhinoMocks\Rhino.Mocks.dll</HintPath>
    </Reference>
    <Reference Include="SharpArch.Domain">
      <HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Domain.dll</HintPath>
    </Reference>
    <Reference Include="SharpArch.NHibernate">
      <HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.NHibernate.dll</HintPath>
    </Reference>
    <Reference Include="SharpArch.Testing">
      <HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Testing.dll</HintPath>
    </Reference>
    <Reference Include="SharpArch.Testing.NUnit">
      <HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Testing.NUnit.dll</HintPath>
    </Reference>
    <Reference Include="SharpArch.Tests">
      <HintPath>..\..\ReferencedAssemblies\SharpArchitecture\SharpArch.Tests.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.SQLite">
      <HintPath>..\..\Packages\System.Data.SQLite.1.0.66.0\lib\System.Data.SQLite.DLL</HintPath>
    </Reference>
    <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\ReferencedAssemblies\ASP.NET MVC\System.Web.Mvc.dll</HintPath>
    </Reference>
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>

PPS:

sql lite config

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
        <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver</property>
        <property name="connection.connection_string">Data Source=:memory:;Version=3;New=True;</property>
        <property name="connection.release_mode">on_close</property>
        <property name="show_sql">true</property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    </session-factory>
</hibernate-configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:38:41+00:00Added an answer on May 23, 2026 at 11:38 am

    There is a couple of the things that could go wrong with sqlite and there are different solutions for different problems, I think the problem you having is because sqlite.dll was built against .net System.Data while what you have is .net 4 System.Data, try adding:

    <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
    </startup>
    

    to the configuration element in the test app.config.

    Also, if you are on x64 machine, and are referencing the x86 sqlite, then you need to change the target framework for your test assembly to x86 (right click project, select properties, build tab, and select x86 for the target framework)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just trying to test for equality in this piece of code, but getting a
I'm trying to test some streaming file upload/download code that I've just written, but
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
Just compiled 5.3.3 from source (win32). Trying to test some header() stuff but it
Just trying to figure out what others are using to test their database procedures
I'm trying to create a very simple REST server. I just have a test
Just trying to get my head around Generics by reading this enlightening article by
I am just trying to test out the new Zend Studio 7.2, and in
I'm trying to use PHPUnit to unit test some class methods that return SQL.
I am just trying to learn some Lisp, so I am going through project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.