Hi!
I am currently having problems with TypeMock on a machine with SQL Server 2008 x64 Developer on Vista x64 Business. The problem is that when I try to run tests in Visual Studio 2008 Professional using TestDriven.NET 2.18.2268 I get an error message saying: "Attempted to read or write protected memory."
Everything worked with SQL Server 2005, but with 2008 it fails consistently on every machine we have tried.
A test does not have to use TypeMock to fail. It is enough for TypeMock to be installed. Uninstalling TypeMock gets the tests running again.
Code to reproduce:
Imports MbUnit.Framework
Imports Microsoft.Practices.EnterpriseLibrary.Data
<TestFixture()> _
Public Class Blopp
<Test()> _
Public Sub PoofGoesTypeMock()
Dim db As Database = DatabaseFactory.CreateDatabase
db.ExecuteNonQuery("IWontGetCalledAnyway", "IAmAParameter", "MeToo")
End Sub
End Class
App.config (to set up EntLib):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="Connection String" />
<connectionStrings>
<add name="Connection String" connectionString="Data Source=.;Initial Catalog=DaBase;integrated security=sspi" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
</configuration>
Needed references:
MbUnit.FrameWork
MbUnit.FrameWork.2.0
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.EnterpriseLibrary.Data
Microsoft.Practices.ObjectBuilder2
Versions:
Vista x64 Business SP1
SQL Server x64 Developer
.NET 3.5 SP1
TypeMock 5.1.2 x64
TestDriven.Net 2.18.2268 (
http://www.testdriven.net/download.aspx)
MbUnit 2.4.2.355 (
http://www.mbunit.com/Downloads.aspx)
MS EntLib 4.1 (
http://msdn.microsoft.com/en-us/library/dd203099.aspx)
I have a project with all needed dll's I can email if you can't reproduce with this info. A database is not needed as it fails before it attempts a connection. Error message suggests it fails on creating the EntLib db object. Full error message:
TestCase 'Blopp.PoofGoesTypeMock'
failed: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, Connection String]) failed: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Strategy type ConfiguredObjectStrategy, index 2)
Microsoft.Practices.ObjectBuilder2.BuildFailedException
Message: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, Connection String]) failed: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Strategy type ConfiguredObjectStrategy, index 2)
Source: Microsoft.Practices.ObjectBuilder2
StackTrace:
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp[TTypeToBuild](IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()
C:TypeMockTypeMockAndEntLibSittingInATreeBlopp.vb(9,0): at TypeMockAndEntLibSittingInATree.Blopp.PoofGoesTypeMock()
Inner Exception
System.AccessViolationException
Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source: Microsoft.Practices.EnterpriseLibrary.Data
StackTrace:
at Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase..ctor(String connectionString)
at Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabaseAssembler.Assemble(String name, ConnectionStringSettings connectionStringSettings, IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)