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 starting to use TypeMock and found the following issue:
When I try to create a database using Microsoft.Practices.EnterpriseLibrary.Data I get the following exception:
"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, Flp]) failed: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Strategy type ConfiguredObjectStrategy, index 2)"
When executing: Database db = DatabaseFactory.CreateDatabase();

I'd like to note that on the specific unit test method I am not mocking anything, this is a unit test on the DAL and I am hitting the database directly. If I remove the reference to TypeMock, TypeMockArrangeActAssert and my test classes from the BLL it works perfectly; I can create the database without any issues.
I am using version 5.3.1.0.
Any idea on how to solve this issue?

Update: I just noticed that it fails if I execute the unit test method using TestDriven.net (right-click) or NUnit run via TMockRunner. It I start directly NUnit it works; of course, my BLL tests failed since the mocks are not enabled (Typemock Isolator is not currently enabled). Also, the tests work if I right click on Debug button from ReShaper.

Thanks,

Teo
asked by teom (2.3k points)

4 Answers

0 votes
Hi Teo,

Can you send me an example of the code that produced the error?
I'll send you a mail from our support.
answered by ohad (35.4k points)
0 votes
Ohad,
With the following example I am able to reproduce the issue:
using Microsoft.Practices.EnterpriseLibrary.Data;
using NUnit.Framework;

namespace MyNameSpace
{
[TestFixture]
public class ExceptionFixture
{
[Test]
public void Test()
{
Database db = DatabaseFactory.CreateDatabase();
}
}
}

The project has a reference to:
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Version 4.1.0.0.

Doing some more testing I found that if I build the application as x86 I am able to use Testdriven.net.
As for NUnit same result. It works if I build my assembly as a x86 and run NUnit: C:Program FilesTypemockIsolator.3>tmockrunner "C:Program Files (x86)NUnit 2.5.1in et-2.0 unit-x86.exe"
So the problem seems to be related to "any cpu"/x64.
For the moment I can compile my unit testing project as x86 and let all other assemblies as "any cpu", but I still would like to know if this is a bug.

Regards,

Teo
answered by teom (2.3k points)
0 votes
Hi Teo,

Thanks for the info, I'll update you on as soon as we'll find something.
answered by ohad (35.4k points)
0 votes
Hi Teo,

I suggest we'll take it offline, I sent you a mail from our support mailbox with some questions.
answered by ohad (35.4k points)
...