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,
after upgrading to TypeMock Isolator 4.2.4, Net1.1, I receive the following error:

TypeMock.TypeMockException: 
*** Method get_MyProperty in type IMyInterface has no matching overload that returns TypeMock.Mock+a.


The error is raised only when I try a null as a return value. How can I fix it? And what is the meaning of TypeMock.Mock+a?

Thanks
asked by Deimos (4.7k points)

9 Answers

0 votes
Hi,

Most likely this is a confusion between the .net 1.1 version of Typemock.dll and the .Net 2.0 version.

try removing all references to Typemock.dll in the vcproj and then re-adding them again.

In Most cases this solves the problem.
answered by lior (13.2k points)
0 votes
Hi Lior,
I followed these steps:

* Install TypeMock 4.2.4
* Open VS, open the solution, remove the old (broken) reference to TypeMock
* Added a new reference to the Net11TypeMock.dll
* Rebuild and relaunch the test

But it's still continue to raise the same error. Is there anything else to check?

Thanks
answered by Deimos (4.7k points)
0 votes
You might be returning a Mock instead of Mock.Object.
Please post a code sample so that we can analysis it.
answered by eli (5.7k points)
0 votes
Hi,
that's a failing example:

   public interface IMyObject
    {        
    }

    public interface IMyInterface
    {
        IMyObject MyObject { get; }
    }

        [Test]
        public void TestFoo()
        {
            MockManager.Init();

            MockObject mockMyInterface = MockManager.MockObject(typeof (IMyInterface));
            mockMyInterface.ExpectGet("MyObject", null);

            IMyInterface myObj = (IMyInterface) mockMyInterface.Object;
            Assert.IsNull(myObj.MyObject);

            MockManager.Verify();
        }


When I try to run the test, I receive the following error:

TypeMock.TypeMockException: 
*** Method get_MyObject in type IMyInterface has no matching overload that returns TypeMock.Mock+a.


More interesting, if I try to use Mock instead of MockObject, I receive another error message, maybe more strange than the first the one. That's the code:

        [Test]
        public void TestFoo()
        {
            MockManager.Init();

            Mock mockMyInterface = MockManager.Mock(typeof (IMyInterface)); //<< error message points here
            mockMyInterface.ExpectGet("MyObject", null);


            MockManager.Verify();
        }


And that's the error message:

TypeMock.TypeMockException: 
*** Cannot type mock Interfaces or Abstract classes use MockObject


Waiting for your feedback,
Thanks,

Deimos
answered by Deimos (4.7k points)
0 votes
Hi Deimos,

Looks like you've discovered a bug :oops: . We'll investigate and send you a patch when we're done.
answered by gilz (14.5k points)
0 votes
Hi Gilz,
do you have any update on this?

Thanks,
Deimos
answered by Deimos (4.7k points)
0 votes
Hi Deimos,

A Patch was sent to you a couple of days ago.
Im guyessing that you did not recevie it for some reason.

I'll resend it shortly. If you dont get it drop me us an email.

Lior
answered by lior (13.2k points)
0 votes
We're running into this bug as well... can I get a release of the patch?
Thanks.

.rob.
rpark@boulderlogic.com
answered by rpark68 (140 points)
0 votes
Hi everyone,

We've just released version 4.3 which fixes this issue. You can download it from https://www.typemock.com/Downloads.php
answered by gilz (14.5k points)
...