Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:59:34+00:00 2026-05-27T08:59:34+00:00

Help! This code works fine on my local VS2010 with TypeMock, however fails on

  • 0

Help!

This code works fine on my local VS2010 with TypeMock, however fails on our build server, when ran through NCover.

My code:

 using (RecordExpectations expect = RecorderManager.StartRecording())
    {
74:             RequestDataLayer.GetAllUsers();
75:             expect.Return(DatabaseUsers);
                // other definitions to follow
    }

Yields this error on a CruiseControl.Net environment:

Execute
TypeMock.TypeMockException: 
*** Cannot use Return in this sequence, there must be a mocked statement first
Perhaps you are trying to mock a method from mscorlib
   at TypeMock.RecordExpectations.b(String A_0)
   at TypeMock.RecordExpectations.a(String A_0)
   at TypeMock.RecordExpectations.Return(Object returnValue)
   at Request.UserSyncTest.SyncData() in UserSyncTest.cs:line 75

The source for the method I try to mock is:

public class RequestDataLayer
{
        public static User[] GetAllUsers()
        {
            // some LINQ magic to get users out of DB, then a .ToArray()
            // returns an object array
        }
}

So there isn’t anything special to it, apart from the fact the method is static. Since then I refactored the method to make it nonstatic, effects on the bottom of this page.

I had a similar issue previously, this was to do with exploiting the Isolate<> syntax of TypeMock, I ran into the same scenario, of tests working fine locally (through Gallio test runner), but failing on the build server (CC.Net, Gallio, TypeMock, NCover).

I’m running 6.0.4.0 of TypeMock on both dev and build boxes.

Also, what seems to have worked was moving lines 74 and 75 down in the RecordExpectations block – the error didn’t show, BUT the method call simply wasn’t mocked silently.

Ideas welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:59:34+00:00Added an answer on May 27, 2026 at 8:59 am

    OK, we found out what the problem was – embarassingly enough TypeMock wasn’t properly called through the NAnt script.

    This is still a mystery however why we didn’t simply see the “TypeMock” is not enabled error message, but this weird behaviour instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with virtual attributes. This code works fine but how do
I've tried everything from reading the Netbeans help to browsing Google. This code works
Help me replace this code, both me and Resharper don't like it: <table width=100%>
Sorry to bother again, but I really need help transforming this Python2 code into
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
HI i did this code with help of Marc Gravell in Why can't I
I need some help understanding this bit of code pre { white-space: pre; white-space:
Can anybody help me with this simple code?? #include <iostream> using namespace std; void
I need help to use jConfirm with this existing code (php & Jquery &
everybody! Could I ask you to help me to decode this JSON code: $json

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.