chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
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)
asked by halstein (8.7k points)

4 Answers

0 votes
Hi
Thanks for the info we'll try to re-produce the problem on our machines.
Meanwhile as workaround you can try running TestDriven.NET as 32 bit process. It might work.
To do this:
open Visual Studio Command Prompt
cd to TestDriven.NET install directory (Default: c:Program Files (x86)TestDriven.NET 2.0)
make sure TestDriven is not running.
use Corflags utility to set TestDriven runner to 32 bit like this:
Corflags /32bit+ ProcessInvocation.exe.

Now try running the tests.
Please tell me if it works.
answered by ohad (35.4k points)
0 votes
Yes, Corflags worked :)
answered by annemarie (140 points)
0 votes
I'm having the same issue, with the same setup. x64 TypeMock 5.3, SQL Server 2008, and Enterprise Library 4.1.
answered by rambl3r1969 (140 points)
0 votes
Hi,

Isolator has a bug with the data application block. Have you tried the solution with Corflags (Assuming you're using TestDriven.NET)? If you're not using TestDriven.NET you can try executing the test in 32bit but in your runner to see if it runs.

Please let me know if it helps.

Regards,
Elisha
Typemock Support Team
answered by Elisha (12k points)
...