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 recently discovered TypeMock.NET and I have to say I think it's really great :D
I have now changed our build script to run our entire test suite through TMockRunner.exe.
The problem is that I am getting a System.InvalidOperationException on 6 tests that previously run just fine. All these tests run against the same method which internally instanciates a System.Xml.Xsl.XslCompiledTransform.

Here are the details of the error:
System.InvalidOperationException : Instances of abstract classes cannot be created.
at System.Diagnostics.SymbolStore.SymDocumentWriter..ctor(ISymUnmanagedDocumentWriter* pDocumentWriter)
at System.Diagnostics.SymbolStore.SymWriter.DefineDocument(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Reflection.Emit.ModuleBuilder.DefineDocumentNoLock(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Reflection.Emit.ModuleBuilder.DefineDocument(String url, Guid language, Guid languageVendor, Guid documentType)
at System.Xml.Xsl.IlGen.XmlILModule.AddSourceDocument(String fileName)
at System.Xml.Xsl.IlGen.GenerateHelper.MarkSequencePoint(ISourceLineInfo sourceInfo)
at System.Xml.Xsl.IlGen.GenerateHelper.MethodBegin(MethodInfo methInfo, ISourceLineInfo sourceInfo, Boolean initWriters)
at System.Xml.Xsl.IlGen.XmlILVisitor.Function(QilFunction ndFunc)
at System.Xml.Xsl.IlGen.XmlILVisitor.Visit(QilExpression qil, GenerateHelper helper, MethodInfo methRoot)
at System.Xml.Xsl.XmlILGenerator.Generate(QilExpression query, AssemblyName asmName)
at System.Xml.Xsl.XslCompiledTransform.CompileIlFromQil(XsltSettings settings)
at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet)


The relevant part of the TypeMock log file shows:

System.Guid instance unsigned int8[] ToByteArray()
System.Runtime.InteropServices.Marshal void Copy(unsigned int8[],int32,int,int32)
System.Runtime.InteropServices.Marshal int StringToCoTaskMemUni(class System.String)
System.IntPtr instance int64 ToInt64()
System.Runtime.InteropServices.Marshal void FreeCoTaskMem(int)
System.Runtime.InteropServices.Marshal bool IsNotWin32Atom(int)
System.Diagnostics.SymbolStore.SymDocumentWriter instance void .ctor(value class System.Diagnostics.SymbolStore.Private.ISymUnmanagedDocumentWriter*)
Sig: 20 01 01 0f 11 2c
IL_0 = ldarg.0
IL_1 = ldstr 0x7000065C
IL_2 = ldstr 0x7000060A
IL_3 = ldnull
IL_4 = ldc.i4.0
IL_5 = call 0x0A000070
IL_6 = brfalse.s 0x69
IL_7 = ldarg.0
IL_8 = ldstr 0x7000065C
IL_9 = ldstr 0x7000060A
IL_10 = ldnull
IL_11 = ldc.i4.0
IL_12 = ldarg.1
IL_13 = ldobj 0x0200000B
IL_14 = box 0x0200000B
IL_15 = call 0x0A000075
IL_16 = dup
IL_17 = ldstr 0x7000065C
IL_18 = ldstr 0x7000060A
IL_19 = ldc.i4.0
IL_20 = call 0x0A000071
IL_21 = brfalse.s 0x20
IL_22 = ldarg.1
IL_23 = ldstr 0x7000065C
IL_24 = ldstr 0x7000060A
IL_25 = ldc.i4.0
IL_26 = call 0x0A000071
IL_27 = unbox 0x0200000B
IL_28 = ldobj 0x0200000B
IL_29 = stobj 0x0200000B
IL_30 = ldstr 0x7000065C
IL_31 = ldstr 0x7000060A
IL_32 = call 0x0A000073
IL_33 = isinst 0x0100005F
IL_34 = brtrue.s 0x02
IL_35 = pop
IL_36 = ret
IL_37 = pop
nop
nop
nop

System.InvalidOperationException instance void .ctor()
System.Environment class System.String GetResourceString(class System.String)
System.Collections.Generic.Dictionary`2 instance void Resize()
<Module> Modifier ? void ReleaseHolder<System::Diagnostics::SymbolStore::Private::ISymUnmanagedDocumentWriter>.{dtor}(Modifier ? Modifier ? value class ReleaseHolder<System::Diagnostics::SymbolStore::Private::ISymUnmanagedDocumentWriter>*)


I figured that it might had something to do with the interception mechanism used by TypeMock.NET being a little too intrusive, so I enabled Fast Mode, in order to intercept only explicitly mocked classes. And sure enough, that works! All tests pass correctly.

Can this be a bug in TypeMock.NET or am I missing something here? By the way, I am using the latest version, 4.0.2.0.

Thanks in advance,
/Enrico
asked by megakemp (3k points)

7 Answers

0 votes
Hi Enrico
Welcome to the forum 8)
Can you tel me please how did you run the tests before switching
to TMockrunner.exe?
Was it the only change you made?

I'll send my mail address off line.
Please send me the full log files and all of the error message stack trace
to this address.
answered by ohad (35.5k points)
0 votes
Hi Ohad,

On the build server we run our tests with NUnit (2.2.8). However this problem manifests itself with any test runner. During development we use TestDriven.NET, now together with the TypeMock.NET Visual Studio add-in, and I get the same exception on those same tests. However, enabling Fast Mode from the configuration add-in solves the problem.

Also note that those failing tests do not make use of TypeMock.NET or any other mocking framework. However, before finding out about TypeMock.NET, we have been using NMock 2.0 in all our test suites.

Regards,
/Enrico
answered by megakemp (3k points)
0 votes
Hi,
Could you please post/send the code that fails, so that we can check this.
answered by scott (32k points)
0 votes
Hi Scott,

I already got confirmation from a member of your support team that this is a bug, and that it will be fixed.
However, the System.InvalidOperationException is raised from the XslCompiledTranform::Load method. Here is the portion of code where the error originates:

// Extracts the XSLT stylesheet from the embedded resources
string resourceName = "ReportToXaml.xslt";
Assembly currentAssembly = Assembly.GetExecutingAssembly();
Stream stylesheet = currentAssembly.GetManifestResourceStream(GetType(), resourceName);

using (XmlTextReader reader = new XmlTextReader(stylesheet))
{
   XslCompiledTransform xslt = new XslCompiledTransform(true); // debug enabled
   xslt.Load(reader);

   return xslt;
}


Regards,
/Enrico
answered by megakemp (3k points)
0 votes
If this is a known bug can anyone let us know the suggested fix date (if known) ? Most appreciated.
answered by pdwebb (1.3k points)
0 votes
Hi
We are still working to fix this problem.
We will send the fix as soon as it ready.
answered by ohad (35.5k points)
0 votes
Hi megakemp and pdwebb
We created a fix and sent it to both of you.
Please check it out.
answered by ohad (35.5k points)
...