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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi,

I am trying to add TypeMock into our NAnt build script. But I am getting an error whilst attempting to load the dll (TypeMock.NAntBuild.dll).

Script snippet below:

[snip]

<!-- Dynamically load TypeMock task. -->
<property name="typemock.dir" value="C:Program FilesTypeMockTypeMock.NET" />
<property name="typemock.tasks" value="${typemock.dir}TypeMock.NAntBuild.dll"/>

<loadtasks assembly="${typemock.tasks}" />

<typemockstart link ="NCover" profilerlaunchedfirst="true" target="2.0"></typemockstart>

<exec program="${NCoverConsoleExe}" workingdir="${NAnt_LogDir}" commandline="&quot;${NUnitConsoleExe}&quot; ${NUnitConfigFile} /config:${BuildConfig} /xml:NUnitTests-results.xml /include:${NUnitIncludeCategories} /nologo /noshadow" output="${NAnt_LogDir}NCover_log.xml failonerror="true"
/>

<typemockstop/>

[snip]


I am getting the error:

test:

[echo] Starting NCover and NUnit test analysis...
[loadtasks] Scanning assembly "TypeMock.NAntBuild" for extensions.
[typemockstart] TypeMock.NET Enterprise License - License will expire in 29 day(s)

BUILD FAILED

INTERNAL ERROR

System.IO.FileNotFoundException: Could not load file or assembly 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file spec
ified.
File name: 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null'
at TypeMock.NAntBuild.TypeMockStartTask.a()
at TypeMock.NAntBuild.TypeMockStartTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.TaskContainer.ExecuteChildTasks()
at NAnt.Core.TaskContainer.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Contrib.Tasks.TryCatchTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].

Any ideas?

Also, does linking to a coverage tool (in my case NCover), remove the need to start and stop TypeMock before running the Unit Tests?

Version Details:

TypeMock 3.7.1
NAnt 0.85
NCover 1.5.5

thanks & regards
Darren
asked by DG (760 points)

9 Answers

0 votes
Hi,
You always have to link/unlink Ncover with typemock.
This is why you should never fail on error between start and stop.
Perhaps it is better to use the trycatch contribution task
<trycatch>
   <try>
      <typemockstart link ="NCover" profilerlaunchedfirst="true" target="2.0"></typemockstart>

      <exec program="${NCoverConsoleExe}" workingdir="${NAnt_LogDir}" 
        commandline="&quot;${NUnitConsoleExe}&quot;  
        ${NUnitConfigFile} /config:${BuildConfig} /xml:NUnitTests-results.xml 
        /include:${NUnitIncludeCategories} 
        /nologo /noshadow"  output="${NAnt_LogDir}NCover_log.xml failonerror="true"/>
   </try>
   <finally>
        <typemockstop/>
   </finally>
</trycatch>

In any case please open the TypeMock Configurator and unlink NCover before running the this build file.

If it still doesn't work. Unlink NCover, Run RegEdit.exe and Make sure that HKEY_CLASSES_ROOTCLSID{6287B5F9-08A1-45E7-9498-B5B2E7B02995}InprocServer32
default key is equal to C:PROGRA~1NCoverCoverLib.dll
answered by scott (32k points)
0 votes
thanks Scott.

An ideas on the first part of the question?

I can't even try your code becuase loading the NAnt dll is failing?

thanks
Darren
answered by DG (760 points)
0 votes
Did you try the following?
Open the TypeMock Configurator and unlink NCover before running nant.

If it still doesn't work. Unlink NCover, Run RegEdit.exe and Make sure that HKEY_CLASSES_ROOTCLSID{6287B5F9-08A1-45E7-9498-B5B2E7B02995}InprocServer32
default key is equal to C:PROGRA~1NCoverCoverLib.dll
answered by scott (32k points)
0 votes
Yes I unlinked NCover via the TypeMock Configurator. Currently my "profiler/Code coverage tool to link to TypeMock.NET" = - None -

I also checked that HKEY_CLASSES_ROOTCLSID{6287B5F9-08A1-45E7-9498-B5B2E7B02995}InprocServer32
default key is equal to C:PROGRA~1NCoverCoverLib.dll. Which it does.

The Nant script currently looks like...

<!-- test - Run Unit Tests and Compile Test Coverage Statistics -->
   <target name="test" depends="build">
      
      <!-- Dynamically load TypeMock task. -->
      <property name="typemock.dir" value="C:Program FilesTypeMockTypeMock.NET" />
      <property name="typemock.tasks" value="${typemock.dir}TypeMock.NAntBuild.dll"/>

      <loadtasks assembly="${typemock.tasks}" />
            
      <trycatch> 
         <try> 
            <typemockstart link ="NCover" profilerlaunchedfirst="true" target="2.0"></typemockstart> 
          
            <exec program="${NCoverConsoleExe}" workingdir="${NAnt_LogDir}" 
            commandline="&quot;${NUnitConsoleExe}&quot;  
            ${NUnitConfigFile} /config:${BuildConfig} /xml:NUnitTests-results.xml 
            /include:${NUnitIncludeCategories} 
            /nologo /noshadow"  output="${NAnt_LogDir}NCover_log.xml" failonerror="true"/> 

         </try> 
         <finally> 
            <typemockstop/> 
         </finally> 
      </trycatch> 

   </target>


The error is still:


test:

[loadtasks] Scanning assembly "TypeMock.NAntBuild" for extensions.
[typemockstart] TypeMock.NET Enterprise License - License will expire in 29 day(s)

BUILD FAILED

INTERNAL ERROR

System.IO.FileNotFoundException: Could not load file or assembly 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file spec
ified.
File name: 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null'
at TypeMock.NAntBuild.TypeMockStopTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.TaskContainer.ExecuteChildTasks()
at NAnt.Core.TaskContainer.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Contrib.Tasks.TryCatchTask.ExecuteTask()
at NAnt.Core.Task.Execute()
at NAnt.Core.Target.Execute()
at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
at NAnt.Core.Project.Execute()
at NAnt.Core.Project.Run()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].


Please send bug report to nant-developers@lists.sourceforge.net.

Total time: 0.4 seconds.
answered by DG (760 points)
0 votes
Hi,
I am not sure why the correct TypeMock.dll is not found.

Please try the following:
1. Open GAC (C:/Windows/assembly) and write the versions of TypeMock.dll that are installed
2. Turn on assembly binding:
Run RegEdit.exe and set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
3. Run the test and post the failure
answered by scott (32k points)
0 votes
Hi Scott,

The version of TypeMock in C:Windowsssembly = TypeMock 3.7.1.0

After turning on Assembly binding the build error is:

test:

[loadtasks] Scanning assembly "TypeMock.NAntBuild" for extensions.
[typemockstart] TypeMock.NET Enterprise License - License will expire in 22 day(s)

BUILD FAILED

INTERNAL ERROR

System.IO.FileNotFoundException: Could not load file or assembly 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file spec
ified.
File name: 'Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null'
   at TypeMock.NAntBuild.TypeMockStopTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.TaskContainer.ExecuteChildTasks()
   at NAnt.Core.TaskContainer.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Contrib.Tasks.TryCatchTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Target.Execute()
   at NAnt.Core.Project.Execute(String targetName, Boolean forceDependencies)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

=== Pre-bind state information ===
LOG: User = OPTISCANDarrenG
LOG: DisplayName = Configuration, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Program Files/NAnt/nant/bin/
LOG: Initial PrivatePath = lib;lib
et.0;lib
et
Calling assembly : TypeMock.NAntBuild, Version=3.7.1.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:Program FilesNAnt
antinNAnt.exe.config
LOG: Using machine configuration file from C:WINDOWSMicrosoft.NETFramework2.0.50727configmachine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.


Please send bug report to nant-developers@lists.sourceforge.net.

Total time: 0.4 seconds.


thanks
Darren
answered by DG (760 points)
0 votes
This is a BUG :twisted: and we will fix it.
Thanks for reporting this. Until we get a fix out the door, here is a workaround.

Add this to your build file:
<copy file="${typemock.dir}Configuration.dll" todir="${nant.location}lib"/>
<copy file="${typemock.dir}	ypemockconfig.xml" todir="${nant.location}lib"/>
<loadtasks assembly="${typemock.tasks}" />


Remember that you will have to manually REMOVE the files once the fix is delivered
answered by scott (32k points)
0 votes
Actually it might not be a bug.

Do you have a file called Configuration.dll in your test/tested assemblies?
answered by scott (32k points)
0 votes
Scott,

No, the application under test does not have any assemblies called "Configuration".

So I agree with your original statement that the bug is with TypeMock. I tried your workaround (copying in the required assemblies in the Nant build script) and the build suceeded (output below).

test:

[loadtasks] Scanning assembly "TypeMock.NAntBuild" for extensions.
[typemockstart] TypeMock.NET Enterprise License - License will expire in 21 day(s)
     [exec] NCover.Console v1.5.7 - Code Coverage Analysis for .NET - http://ncover.org
     [exec] Copyright (c) 2004-2006 Peter Waldschmidt
     [exec] Command: C:Program FilesNUnit 2.4in
unit-console.exe
     [exec] Command Args: "C:CodeOptiscanSoftwareGlobal.nunit" "/config:Debug" "/xml:NUnitTests-results.xml" "/include:Global" "/nologo" "/noshadow"
     [exec] Working Directory:
     [exec] Assemblies:
     [exec] Coverage Xml: Coverage.Xml
     [exec] Coverage Log: Coverage.Log
     [exec] Waiting for profiled application to connect...Connected
     [exec] Configuring Profiler...
     [exec] ******************* Program Output *******************
     [exec] Included categories: Global
     [exec] ......
     [exec] Tests run: 6, Failures: 0, Not run: 0, Time: 1.014 seconds
     [exec] ***************** End Program Output *****************


thanks a lot for your help! I'm impressed by the level of support provided.

Darren
answered by DG (760 points)
...