Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

AccessViolationException when running from Nant task

+3 votes
Somebody already had the problem but their was with a different version and seemed to involve NCover.
I am using version v5.4.5.0. I have both the 32-bit and 64-bit versions installed on my box, because different launching programs seem to need different versions. When running from inside VisualStudio through ReSharper everything works fine, however when running from Nant I get:
[gallio] System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
[gallio] at System.ServiceModel.Description.ConfigLoader.CheckAccess(IConfigurationContextProviderInternal element)
[gallio] at System.ServiceModel.Description.ConfigLoader.LookupService(String serviceConfigurationName)
[gallio] at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
[gallio] at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
[gallio] at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
[gallio] at System.ServiceModel.ServiceHost..ctor(Object singletonInstance, Uri[] baseAddresses)
[gallio] at ControllerTest.ControllerServiceTest.SetUp() in d:\ControllerTest\ControllerServiceTest.cs:line 56
asked Jan 26, 2010 by ScottR (750 points)

19 Answers

0 votes
Hi Scott,

Can you please give me more details about the run?
What exactly are you running? (Test runner, coverage tool etc.)
Can you please post the part of the script that runs with the Isolator?

Also note that you on Isolator versions before version 6.0 you can not use the 32 bit installer on 64 bit machines.
From version 6.0 there is one installer for both platforms.
answered Jan 26, 2010 by ohad (37,080 points)
+3 votes
Sorry for the late response, I assumed that when I clicked "watch this topic" that it would send me an e-mail when it changed. I was just stopping by to check how long it had been when I noticed your response.

Here is an excerpt of the script:
<target name="gallio" failonerror="true">
<!-- Dynamically load TypeMock task. -->
<loadtasks assembly="${typeMockTasks}" />
<typemockregister company="<deleted>" license="<deleted>" autodeploy="true"/>
<!-- Dynamically load Gallio task. -->
<loadtasks assembly="${gallioNantTasks}" />

<gallio report-directory="BuildResults"
report-name-format="T6000NativeTest"
report-types="Xml-Inline;Html"
show-reports="${showReports}"
result-property="ExitCode1"
failonerror="false">
<plugin-directories>
<include name="${gallioBase}" />
</plugin-directories>
<files>
<include name="InstrumentUtilitiesTest\bin\${flavor}\InstrumentUtilitiesTest.dll" />
</files>
</gallio>

<gallio runner-type="TypeMock"
report-directory="BuildResults"
report-name-format="T6000MockedTest"
report-types="Xml-Inline;Html"
show-reports="${showReports}"
result-property="ExitCode2"
failonerror="false">
<plugin-directories>
<include name="${gallioBase}" />
</plugin-directories>
<files>
<include name="ControllerTest\bin\${flavor}\ControllerTest.dll" />
</files>
</gallio>
<fail if="${ExitCode1 != '0'}" >The return code should have been 0!</fail>
<fail if="${ExitCode2 != '0'}" >The return code should have been 0!</fail>
<typemockstop undeploy="true" />
</target>



With these defines:
<property name="gallioBase" value="${project::get-base-directory()}\..\External\Gallio\v3.1.397.0" />
<property name="gallioNantTasks" value="${gallioBase}\Gallio.NAntTasks.dll" />
<property name="typeMockBase" value="${project::get-base-directory()}\..\External\TypeMock\v5.4.5.0" />
<property name="typeMockTasks" value="${typeMockBase}\TypeMock.NAntBuild.dll" />


Also you are right about the installed versions the other version looks like an orpahned directory.
answered Feb 2, 2010 by ScottR (750 points)
+2 votes
Hi,

What version of NCover are you using?

Regards,
Elisha,
Typemock Support
answered Feb 2, 2010 by Elisha (22,740 points)
+3 votes
I have not linked TypeMock with NCover.
answered Feb 2, 2010 by ScottR (750 points)
+2 votes
Hi,

Forget about the NCover question, I confused it with the comment from the first post :)

This issue happens most likely due to a mismatch between x86 & x64 processes. I would like to try something in order to see if this is the problem.

Set Nant to run in 32bit mode (in VS command prompt: corflags /32bit+ NAnt.exe). Then, run again the build script using that Nant.exe and let me know if the script runs correctly.

Regards,
Elisha,
Typemock Support
answered Feb 3, 2010 by Elisha (22,740 points)
+3 votes
That might have helped (I forgot to grab a before snapshot), but I still have at least 8 failing unit tests with the same error. Could it be something related to Gallio?

[loadtasks] Scanning assembly "Gallio.NAntTasks" for extensions.
[gallio] Gallio NAnt Task - Version 3.1 build 397
[gallio] Start time: 1:10 PM
[gallio] Stop time: 1:10 PM (Total execution time: 18.881 seconds)
[gallio] Gallio NAnt Task - Version 3.1 build 397
[gallio] Start time: 1:10 PM
[gallio] Starting TypeMock.
[gallio] [failed] Test ControllerTest/BiosensorWorkflowTest/TestSaveSpectralD
ata/TestSaveSpectralData(true)
[gallio] Execute
[gallio] System.AccessViolationException: Attempted to read or write protecte
d memory. This is often an indication that other memory is corrupt.
answered Feb 9, 2010 by ScottR (750 points)
+3 votes
Any word on this?
answered Feb 26, 2010 by ScottR (750 points)
+2 votes
Hi Scott,

Sorry for not answering you sooner, Is it possible to create a simple test project we can run on our side and investigate this issue?
answered Feb 26, 2010 by dhelper (23,700 points)
+3 votes
Sorry for not replying for a while, I had some other higher priority issues that came up. Could this have something to do with the following dialog:
Version mismatch the installed version (5.2.3.0) differs from the loaded version (5.4.5.0).

The crazy thing is that I don't (as far as I can tell) have 5.2.3.0 installed anywhere on this machine. However I am pretty sure that 5.2.3 was the originally licensed version by the company that I am currently working with. Unfortunately that didn't work for me, because I have a 64-bit system. Is the licensed version somehow cached? Do I need to clear out something?
answered Mar 23, 2010 by ScottR (750 points)
0 votes
Hi Scott,

This indeed could be the problem source.
This exception can happen when you have older TypeMock.dll in the GAC or when an older version of TypeMock.dll is in the build directory. Than at runtime the older version gets loaded. This can create unpredictable results and for that reason the Isolator tries to detects this scenario.

The solution is simple:
First check the GAC at this path: "c:\Windows\assembly"
If you have more than one TypeMock.dll in gac please remove the older one.
Check the local directory and see if you have older version of TypeMock.dll
If you find one remove it than make sure you are referencing the new version and rebuild.

Please let me know if that solves your problem.
answered Mar 23, 2010 by ohad (37,080 points)
...