locked
Problems after installing Visual Studio 2010 SP1

    Question

  • Hi,

    Last Friday I installed Visual Studio SP1 on my machine and Moles stopped compiling. Following you can find some examples of the kind of errors I get on Visual Studio Error List:

    1. 'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [D:\...\MyProject\obj\Debug\Moles\s\m.g.csproj]
    2. 'System.Net.Moles.SFileWebResponse.SupportsHeaders': no suitable method found to override [D:\...\MyProject\obj\Debug\Moles\s\m.g.csproj]
    3. The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\...\MyProject\obj\Debug\Moles\moles.args"" exited with code -1007
    4. Cannot call an abstract base member: 'System.Xml.XmlReader.Close()' [D:\...\MyOtherProject\obj\Debug\Moles\sx\m.g.csproj]
    5. The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\...\MyOtherProject\obj\Debug\Moles\moles.args"" exited with code -1002

    I've tried everything I imagined: uninstalling SP1, repairing the installation of Visual Studio, re-installing Visual Studio + Pex & Moles... but I still get th same problems.

    My version of Pex & Moles is 0.94.51006.1 (x86).

    Any ideas why is is happening and how can I solve it?

    Thanks very much.

    Monday, March 14, 2011 11:28 AM

All replies

  • It seems Moles is generating some temporary files that produce the following pattern when applied to certain assemblies, like System.Xml:

    http://msdn.microsoft.com/en-us/library/b307b7dc(v=vs.90).aspx

    Such pattern doesn't compile. To be precise, this is happening in the moles generated for XmlReader, XmlWriter and XmlResolver. Being both XmlReader and XmlWriter abstract, the XmlReader and XmlWriter moles are calling their base classes Close() method within the implementation of their Close() method. The XmlResolver is doing the same with the Credentials property.

    In order to reproduce this, I have just created a new Class Library project and I've added a mole for System.Xml assembly. That's it. No other modification, and the generated code is as follows:

    namespace System.Xml.Moles
    {
      /// <summary>Stub type of <see cref="T:System.Xml.XmlReader"/>
      /// .</summary>
      [mmf::Microsoft.Moles.Framework.Stubs.StubClass(typeof(global::System.Xml.XmlReader))]
      [global::System.Diagnostics.DebuggerDisplay("Stub = XmlReader")]
      [global::System.Diagnostics.DebuggerNonUserCode]
      public partial class SXmlReader
       : global::System.Xml.XmlReader
       , mmf::Microsoft.Moles.Framework.Stubs.IPartialStub
       , mmf::Microsoft.Moles.Framework.Stubs.IStub
      {
        
        // more code here
    
        /// <summary>Sets the stub of <see cref="M:System.Xml.XmlReader.Close"/>
        /// </summary>
        public override void Close()
        {
          mmf::Microsoft.Moles.Framework.MolesDelegates.Action sh = this.Close01;
          if (sh != (mmf::Microsoft.Moles.Framework.MolesDelegates.Action)null)
           sh.Invoke();
          else 
          {
           if (this.__callBase)
            base.Close();
           else 
           {
            mmf::Microsoft.Moles.Framework.Behaviors.IBehavior _behavior
              = ((mmf::Microsoft.Moles.Framework.Behaviors.IBehaved)this).InstanceBehavior;
            _behavior.VoidResult<global::System.Xml.Moles.SXmlReader>(this, "Close");
           }
          }
        }
        
        // more code here
      }
    }

    Monday, March 14, 2011 2:42 PM
  • I've just compared the code Moles generates in my machine with the one generated in a colleague's machine. There are a few differences in the System.Xml moles, but here you have one:

    Part of my auto-generated code for XmlReader (same as previous post):

     

    public override void Close()
    {
     mmf::Microsoft.Moles.Framework.MolesDelegates.Action sh = this.Close01;
     if (sh != (mmf::Microsoft.Moles.Framework.MolesDelegates.Action)null)
      sh.Invoke();
     else 
     {
      if (this.__callBase)
      base.Close();
      else 
      {
      mmf::Microsoft.Moles.Framework.Behaviors.IBehavior _behavior
       = ((mmf::Microsoft.Moles.Framework.Behaviors.IBehaved)this).InstanceBehavior;
      _behavior.VoidResult<global::System.Xml.Moles.SXmlReader>(this, "Close");
      }
     }
    }
    

    Part of my colleague's auto-generated code for XmlReader:

     

    public override void Close()
    {
     mmf::Microsoft.Moles.Framework.MolesDelegates.Action sh = this.Close01;
     if (sh != (mmf::Microsoft.Moles.Framework.MolesDelegates.Action)null)
      sh.Invoke();
     else 
     {
      mmf::Microsoft.Moles.Framework.Behaviors.IBehavior _behavior = ((mmf::Microsoft.Moles.Framework.Behaviors.IBehaved)this).InstanceBehavior;
      _behavior.VoidResult<global::System.Xml.Moles.SXmlReader>(this, "Close");
     }
    }
    

     

    Notice the else part. His Moles auto-generated code does not have the if (this.__callBase) bit.

     

     

    Monday, March 14, 2011 3:13 PM
  • Hi,

    Last Friday I installed Visual Studio SP1 on my machine and Moles stopped compiling. Following you can find some examples of the kind of errors I get on Visual Studio Error List:

    1. 'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [D:\...\MyProject\obj\Debug\Moles\s\m.g.csproj]
    2. 'System.Net.Moles.SFileWebResponse.SupportsHeaders': no suitable method found to override [D:\...\MyProject\obj\Debug\Moles\s\m.g.csproj]
    3. The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\...\MyProject\obj\Debug\Moles\moles.args"" exited with code -1007
    4. Cannot call an abstract base member: 'System.Xml.XmlReader.Close()' [D:\...\MyOtherProject\obj\Debug\Moles\sx\m.g.csproj]
    5. The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\...\MyOtherProject\obj\Debug\Moles\moles.args"" exited with code -1002

    I've tried everything I imagined: uninstalling SP1, repairing the installation of Visual Studio, re-installing Visual Studio + Pex & Moles... but I still get th same problems.

    My version of Pex & Moles is 0.94.51006.1 (x86).

    Any ideas why is is happening and how can I solve it?

    Thanks very much.


    After upgrading Visual Studio 2010 to SP1 we experience similar problems. We can no longer build a project that contains some moles on the System.ServiceModel assembly. We are using the same version of Pex & Moles as described in the post above. Also tried updating to Pex & Moles version v0.94.51023.0, but this did not solve the problem either.

    Error 58 The type or namespace name 'IHttpCookieContainerManager' does not exist in the namespace 'ssm::System.ServiceModel.Channels' (are you missing an assembly reference?) [...\obj\Debug\Moles\ssm\m.g.csproj] ...\m.g.cs line 293022

    Error 83 The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @...\obj\Debug\Moles\moles.args" exited with code -1002.

    The relevant section of the code generated by moles is shown below:

    namespace System.ServiceModel.Channels.Moles
    {
     /// <summary>Stub type of <see cref="T:System.ServiceModel.Channels.IHttpCookieContainerManager"/>
     /// .</summary>
     [mmf::Microsoft.Moles.Framework.Stubs.StubClass(typeof(ssm::System.ServiceModel.Channels.IHttpCookieContainerManager))]
     [global::System.Diagnostics.DebuggerDisplay("Stub = IHttpCookieContainerManager")]
     [global::System.Diagnostics.DebuggerNonUserCode]
     public partial class SIHttpCookieContainerManager
     : mmf::Microsoft.Moles.Framework.Stubs.StubBase
    <strong> , ssm::System.ServiceModel.Channels.IHttpCookieContainerManager
    </strong> {
    

    Any ideas on how to solve this?

    Thanks in advance.

     

     

     

    • Edited by Aquariusquintini Thursday, March 17, 2011 12:17 PM Tried latest version of Pex & Moles
    Thursday, March 17, 2011 10:59 AM
  • A bit further investigation into the problem reveiled me that we also get the same errors as the ones mentioned in the first post. We haven't found a solution to the problem in the mean time, so we will remove SP1 of Visual Studio 2010 from our dev machines for now until a solution is found.

    Any ideas on how to solve this?

    Thanks in advance.

    Wednesday, March 23, 2011 12:14 PM
  • Try updating the System.ServiceModel.moles file to use reflection only:

     

    <Moles xmlns="http://schemas.microsoft.com/moles/2010/">
      <Assembly Name="System.ServiceModel" ReflectionOnly="true"/>
    </Moles>

     

    That worked for me.

    Wednesday, March 23, 2011 1:12 PM
  • Try updating the System.ServiceModel.moles file to use reflection only:

     

    <Moles xmlns="http://schemas.microsoft.com/moles/2010/">
      <Assembly Name="System.ServiceModel" ReflectionOnly="true"/>
    </Moles>

     

    That worked for me.


    That seems to work, no idea why but I can compile my projects again. That's great, I don't have to deinstall SP1 now.
    Wednesday, March 23, 2011 3:25 PM