Giter Club home page Giter Club logo

Comments (51)

adamralph avatar adamralph commented on May 18, 2024 2

Is this not a case of having "Break when an exception is thrown" checked?

from fakeiteasy.

philippdolder avatar philippdolder commented on May 18, 2024

I assume your code is ITest tt = A.Fake<ITest>(); ? otherwise it shouldn't compile at all.

can you provide some more code, please? best would be a minimal sample sln that reproduces the problem.
is COM involved somehow?

can you write the same test with a different testing framework? (eg. xunit or nunit?)

from fakeiteasy.

sergyr avatar sergyr commented on May 18, 2024

the problem seems to be in the solution. I created a test test project
within an existing solution, and got the same exception when trying to
initiate a debug session. When I created a test project in brand new
solution, everything was fine. So I removed *.suo and was able to step
through beyond the first line which creates a fake object. which was ITest
tt = A.Fake() and is not even my test code. Just happened to be the
first line where I use fake framework. so I proceeded with
changing/debugging my project, then returned back to the test project, run
tests - all was great, started to debug test project, I was getting the
same exception. So I am attaching a solution with a test project where I
can reproduce the problem.

-Sergey

On Mon, Jan 28, 2013 at 9:40 AM, Philipp Dolder [email protected]:

I assume your code is ITest tt = A.Fake(); ? otherwise it
shouldn't compile at all.

can you provide some more code, please? best would be a minimal sample sln
that reproduces the problem.
is COM involved somehow?

can you write the same test with a different testing framework? (eg. xunit
or nunit?)


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-12784381.

from fakeiteasy.

philippdolder avatar philippdolder commented on May 18, 2024

Hi Sergey

The attachment didn't get into your comment. So I don't get the source code. In case you can't attach the code to the comment here on github, Send me a personal message on twitter (@philippdolder) so I can provide you with an E-Mail address

from fakeiteasy.

jimmyheaddon avatar jimmyheaddon commented on May 18, 2024

Hi Philipp,

I'm getting the same using NUnit against the FakeItEasy NuGet package version 1.10.0, "MissingMethodException: Cannot create an instance of an interface."

I have the source VS2012 C# solution for you, but GitHub won't let me attach a .zip? Any ideas how I can get this to you? Drop me a line on here or email --removed email--

Cheers!

from fakeiteasy.

philippdolder avatar philippdolder commented on May 18, 2024

@jimmyheaddon I just sent you an email

from fakeiteasy.

jimmyheaddon avatar jimmyheaddon commented on May 18, 2024

Attachment should be on it's way, thanks Phillip 👍

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

Assigning P3 since no activity for a while.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

@philippdolder did anything come out of this?

@sergyr is this still a problem for you?

from fakeiteasy.

sergyr avatar sergyr commented on May 18, 2024

I moved on ... i think creating a brand new solution helped.

-Sergey

On Sun, Feb 23, 2014 at 8:37 PM, Adam Ralph [email protected]:

@philippdolder https://github.com/philippdolder did anything come out
of this?

@sergyr https://github.com/sergyr is this still a problem for you?


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-35851558
.

from fakeiteasy.

philippdolder avatar philippdolder commented on May 18, 2024

@adamralph I had a look into it and sent feedback and more questions to @jimmyheaddon but didn't get a reply so far.

I couldn't reproduce the issue on my side at that time. But I gave @jimmyheaddon some TDD advice on getting a better test design.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

@philippdolder what's your opinion? Worth keeping this open and investigating or shall we close it since we failed to reproduce and have had no further feedback?

from fakeiteasy.

sergyr avatar sergyr commented on May 18, 2024

the attachment I sent when I opened the case is here
https://drive.google.com/file/d/0B9u8-jfVuN40UXByWTVhcHdkM2FQNWtWa1ZNS2d3WUw2Ri1F/edit?usp=sharing

you can use it to reproduce

-Sergey

On Thu, Feb 27, 2014 at 7:53 AM, Adam Ralph [email protected]:

@philippdolder https://github.com/philippdolder what's your opinion?
Worth keeping this open and investigating or shall we close it since we
failed to reproduce and have had no further feedback?


Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-36238631
.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

Thanks @sergyr

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@sergyr, @adamralph, @philippdolder, I just tried to reproduce using @sergyr's package, but was unable to. The tests worked fine using FakeItEasy 1.7.4626.65 (provided with the solution) and with 1.23, debugging via the MSTest Runner and under TestDriven.NET.

Is it worthwhile keeping the issue open?

from fakeiteasy.

philippdolder avatar philippdolder commented on May 18, 2024

@blairconrad I think we can close it

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@linvi created #349, to say

This is a copy of the bug : #33
When using Visual Studio 2013 and debugging, the test fails as I receive MissingMethodException.

I've since closed that issue in favour of talking here.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@linvi, thanks for reporting the bug. Do you have a sample test or project or solution that we can have to investigate? We've been unable to reproduce on our own.

Also, can you tell us whether the failure happens every time, or is sporadic?
Does shutting down Visual Studio fix it?

Thanks, Blair

from fakeiteasy.

linvi avatar linvi commented on May 18, 2024

Hello,

Please download the source code of Tweetinvi (https://tweetinvi.codeplex.com/SourceControl/latest).
Open the Development - 0.9.4.x folder and open the Tweetinvi.sln project.

All the tests pass but if you run any of it in debug mode, it won't work.
I have been updated to the latest version of FakeItEasy 3 weeks ago and needed to debug one only yesterday.

You can also have a look into the FakeClassBuilder that I created and that I think should be a great feature for FakeItEasy.

Regards,
Linvi

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Thanks, @linvi. I'm in UTC-4 and at the Day Job, but will try to set some time aside tonight or before work tomorrow.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Bad(?) news, @linvi. I debugged the lot of them, and they all worked.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Oh, I forgot to talk about FakeClassBuilder. We should probably pursue that in another issue to avoid confusing things. From the name, I'm guessing it's doing something at least superficially like some of the functionality in https://code.google.com/p/autofac/wiki/FakeItEasy, but I'm probably wrong.

If you'd like to create an issue, pointing out features of the FakeClassBuilder code and what benefit you think it brings, I'd be happy to take a look.

from fakeiteasy.

megakid avatar megakid commented on May 18, 2024

Hmm I'm getting the same thing - MissingMethodException "Cannot create instance of interface". Only when debugging in VS2012 (not tried other versions) and used 1.17 and 1.24. Restarted VS and no change. Early doors currently but inside my test project I have this file:

using FakeItEasy;
using NUnit.Framework;

namespace TestSpace
{
    public interface IChoice
    {
        string ChoiceName { get; }
    }

    [TestFixture]
    public class Tests
    {
        [Test]
        public void Test()
        {
             IChoice choice = A.Fake<IChoice>();
        }
    }
}

As above, this probably confirms that it's more to do with the solution setup more than the actual code.

Not sure where to go from here as we have a large solution that can't be rebuilt easily.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Thanks for piling on, @megakid. Indeed, it does sound like there's something deeper going on, as that test is about as vanilla as they get.
Of course, I took @linvi's solution and could not reproduce.
I continue to be stumped…

Oh. How exactly do you start the debugging session? What test runner are you using in Visual Studio?

from fakeiteasy.

megakid avatar megakid commented on May 18, 2024

@blairconrad A machine reboot cured the problem.

I was using NCrunch and ReSharper test runners to start the debugging session. Very odd.

from fakeiteasy.

linvi avatar linvi commented on May 18, 2024

@blairconrad Personally the error still occurs after reboot.
But it might be related with Visual Studio as I can debug the same tests on another machine perfectly well.

Still, the problem happens with FakeItEasy, I will try to investigate with you more about this problem but it might not be your fault at all.

The biggest problem comes from the fact that for libraries like the one I am working with, I cannot undo the project and restart if from scratch so this is quite annoying.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Odd indeed. (Almost) All I use is ReSharper to run my tests. Of course, at the Day Job I use VS2010, and VS2013 at home.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@linvi, do you have a full stack trace we could at least look at in the meantime? The only one we've seen (from the original post) seems to be cut off.
Thanks.

from fakeiteasy.

linvi avatar linvi commented on May 18, 2024

Well, I don't believe the stack trace will help a lot. The error occurs as soon as you try to create an object of type Fake.

But please feel free to analyze it.

Error : {"Cannot create an instance of an interface."}

Full StackTrace:

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

CallStack:

UserControllerTests.TestInitialize
FakeClassBuilder.Ctor
FakeClassBuilder.InitializeContainer

Failing on line 40: var fakeInstance = Activator.CreateInstance(parameterFakeType);
Please note that this is failing also if I create the Fake object from the A.Fake<>().

Thanks for the time and help.
Linvi

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Thanks for that. It is interesting.

When it fails, what's parameterFakeType? I'm not sure how it would ever not be a Fake<something>, but if Activator.CreateInstance thinks it's an interface, I had to ask.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

Do we have any outcome from this yet? Any enhancement need introducing or bug need fixing?

from fakeiteasy.

megakid avatar megakid commented on May 18, 2024

Hi Adam, I got a notification of your message and thought to myself I havent seen it in a while but I just had it crop up again. Again, a full machine reboot cured it. It seems something deeper is going wrong. Since I just jumped to a full reboot, I didn't bother doing much debugging.

The only thing I can tell you this time is that I was in the process of faking with some internal interfaces (with other internal interfaces as property return types etc), after a little back and forth (mostly creating internal interfaces for classes that I had used in those interfaces, then using that interface across my domain instead of the class itself), I eventually added InternalsVisibleTo to the corresponding assemblies (to both DynamicProxy and my test class), this error cropped up.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

I guess since neither @philippdolder nor @blairconrad were able to reproduce the issue, the only way we can proceed is for someone who encounters the issue to do a full investigation and try and find out the root cause?

I'm suspecting it's something outside FakeItEasy, but it would be interesting and useful to know what it is, to help out anyone who has the problem in the future.

from fakeiteasy.

hshilling avatar hshilling commented on May 18, 2024

I also have been using this successfully in other projects and then ran into this.
I changed the code locally as below:

fakeit

i.e., ignore interfaces for construction.

Below is the stack where it died (dies on try to create FakeItEasy.IDummyFactory):

mscorlib.dll!System.RuntimeType.CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache, ref System.Threading.StackCrawlMark stackMark)  Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, bool nonPublic)  Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type)  Unknown

FakeItEasy.dll!FakeItEasy.Core.TypeCatalogueInstanceProvider.InstantiateAllOfType<FakeItEasy.IDummyFactory>() Line 35 C#
FakeItEasy.dll!FakeItEasy.ImportsModule.RegisterEnumerableInstantiatedFromTypeCatalogue.AnonymousMethod__5<FakeItEasy.IDummyFactory>(FakeItEasy.IoC.DictionaryContainer c) Line 32 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.SingletonResolver<System.Collections.Generic.IEnumerable<FakeItEasy.IDummyFactory>>.UnresolvedState.Resolve(FakeItEasy.IoC.DictionaryContainer container) Line 126 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.SingletonResolver<System.Collections.Generic.IEnumerable<FakeItEasy.IDummyFactory>>.Resolve(FakeItEasy.IoC.DictionaryContainer container) Line 79 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Register<System.Collections.Generic.IEnumerable<FakeItEasy.IDummyFactory>>.AnonymousMethod__0(FakeItEasy.IoC.DictionaryContainer c) Line 52 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Resolve(System.Type componentType) Line 41 C#
FakeItEasy.dll!FakeItEasy.ServiceLocator.Resolve<System.Collections.Generic.IEnumerable<FakeItEasy.IDummyFactory>>() Line 24 C#
FakeItEasy.dll!FakeItEasy.Core.FakeScope.RootScope.RootScope() Line 198 C#
FakeItEasy.dll!FakeItEasy.Core.FakeScope.FakeScope() Line 18 C#
[Native to Managed Transition]
FakeItEasy.dll!FakeItEasy.RootModule.RegisterDependencies.AnonymousMethod__2(FakeItEasy.IoC.DictionaryContainer c) Line 34 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Register<FakeItEasy.Core.FakeScope>.AnonymousMethod__0(FakeItEasy.IoC.DictionaryContainer c) Line 52 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Resolve(System.Type componentType) Line 41 C#
FakeItEasy.dll!FakeItEasy.ServiceLocator.Resolve<FakeItEasy.Core.FakeScope>() Line 24 C#
FakeItEasy.dll!FakeItEasy.RootModule.RegisterDependencies.AnonymousMethod__3(FakeItEasy.IoC.DictionaryContainer c) Line 37 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Register<FakeItEasy.Core.IFakeObjectContainer>.AnonymousMethod__0(FakeItEasy.IoC.DictionaryContainer c) Line 52 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Resolve(System.Type componentType) Line 41 C#
FakeItEasy.dll!FakeItEasy.ServiceLocator.Resolve<FakeItEasy.Core.IFakeObjectContainer>() Line 24 C#
FakeItEasy.dll!FakeItEasy.RootModule.RegisterDependencies.AnonymousMethod__1c(FakeItEasy.IoC.DictionaryContainer c) Line 98 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Register<FakeItEasy.Creation.IFakeAndDummyManager>.AnonymousMethod__0(FakeItEasy.IoC.DictionaryContainer c) Line 52 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Resolve(System.Type componentType) Line 41 C#
FakeItEasy.dll!FakeItEasy.ServiceLocator.Resolve<FakeItEasy.Creation.IFakeAndDummyManager>() Line 24 C#
FakeItEasy.dll!FakeItEasy.RootModule.RegisterDependencies.AnonymousMethod__1b(FakeItEasy.IoC.DictionaryContainer c) Line 93 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Register<FakeItEasy.Creation.IFakeCreatorFacade>.AnonymousMethod__0(FakeItEasy.IoC.DictionaryContainer c) Line 52 C#
FakeItEasy.dll!FakeItEasy.IoC.DictionaryContainer.Resolve(System.Type componentType) Line 41 C#
FakeItEasy.dll!FakeItEasy.ServiceLocator.Resolve<FakeItEasy.Creation.IFakeCreatorFacade>() Line 24 C#
FakeItEasy.dll!FakeItEasy.A.FakeCreator.get() Line 24 C#
FakeItEasy.dll!FakeItEasy.A.Fake<Qmastor.PitToPort.Server.DataProvider.Interfaces.GenericFilter.IGenericFilterDataProvider>() Line 35 C#
Qmastor.Server.Mock.Tests.dll!Qmastor.Server.Mock.Tests.UtilityDataService.SaveGenericBillboardFilterCommandTests.CalculateColumnSqlSelectBlock_WhenRequestHas2ColumnSelected_CalculatedSelectClauseWillHave2Columns() Line 19 C#
[Native to Managed Transition]
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.DefaultTestMethodInvoke(object[] args) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.RunTestMethod() Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.ExecuteTest() Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.ExecuteInternal() Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.Execute() Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.UnitTestRunner.RunInternal(Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethod testMethod, bool isDataDriven) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.MSTestFramework.UnitTestRunner.RunSingleTest(string name, string fullClassName, bool isAsync) Unknown
[AppDomain (vstest.executionengine.x86.exe�, #1) -> AppDomain (UnitTestAdapter: Running test�, #2)]
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.ExecuteTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, Microsoft.VisualStudio.TestPlatform.MSTestFramework.UnitTestRunner testRunner, Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.TmiTestRun tmiTestRun) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.ExecuteDurontoTestsInternal(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, string source, Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestRunDirectories runDirectories, Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.TmiTestRun tmiTestRun) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.ExecuteDurontoTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, string source, Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestRunDirectories runDirectories, Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.TmiTestRun tmiTestRun) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.ExecuteTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestRunDirectories runDirectories, bool isDeploymentDone, string source) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.ExecuteTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestRunDirectories runDirectories, bool isDeploymentDone) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MixedModeExecutor.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.TestRunCancellationToken cancellationToken) Unknown
Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.dll!Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.MSTestExecutor.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle) Unknown
Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestInternalWithExecutors(System.Collections.Generic.IEnumerable<System.Uri> executorUris, bool hasTests, System.Collections.Generic.Dictionary<System.Uri,System.Collections.Generic.IEnumerable> executorUriVsSourceList, System.Collections.Generic.Dictionary<System.Uri,System.Collections.Generic.List<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>> executorUriVsTestList, Microsoft.VisualStudio.TestPlatform.Core.RunContext runContext, long totalTests, Microsoft.VisualStudio.TestPlatform.Core.Utilities.MeasurementBlockWrapper mb) Unknown
Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestsInternal(System.Collections.Generic.IEnumerable testOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext) Unknown
Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(System.Collections.Generic.IEnumerable testsOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext) Unknown
Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(object data) Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj) Unknown

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@hshilling, thanks for chiming in. I'm a little confused about the order of things. Can you help me make sure I understand correctly?

My understanding is that you'd been using FakeItEasy successfully in other projects, and then tried using it in a new project (solution?), where you encountered the "System.MissingMethodException occurred
Message=Cannot create an instance of an interface." problem.
You determined that the trouble was with FakeItEasy trying to instantiate an IDummyFactory, so you added the guard against creating interfaces and then the problem went away?

from fakeiteasy.

hshilling avatar hshilling commented on May 18, 2024

Mostly right. I had been using fake it easy no probless in my first already existing solution with 50 plus projects under debug in vs2013 with first chance exceptions turned on. Then I added some tests to an already existing but different solution and got the problem. I imagine running the tests in this second solution without debugging encounters the same issue but the error is swallowed and the debugger does not break in. Not sure why this second solution is trying to create an idummyfactory, maybe it tried to resolve the concrete class earlier on and failed?

from fakeiteasy.

hshilling avatar hshilling commented on May 18, 2024

Either way my tests seem to work as expected in this second solution with the guard in place. Maybe the stack trace I added will tell you something.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Cool, @hshilling. Thanks for the extra info.
The stack trace was great, and certainly pinpointed the problem you were having.
FakeItEasy always tries to create an IDummyFactory—it tries to create one of every type that implements IDummyFactory.
There's really no reason for it to though, and the indiscriminate catch usually hides the exception, but if you're breaking on first chance exceptions, I guess that would make the difference. Whether this is the problem that everyone else who chimed in on the issue was having or not, I think it's something that should be fixed.
I'm a little leery of saying that it will fix this issue, but I'll spin off another one.

from fakeiteasy.

hshilling avatar hshilling commented on May 18, 2024

Ok thanks for that, will let you know if I notice any issues.
On 11/06/2015 11:31 am, "Blair Conrad" [email protected] wrote:

Cool, @hshilling https://github.com/hshilling. Thanks for the extra
info.
The stack trace was great, and certainly pinpointed the problem you were
having.
FakeItEasy always tries to create an IDummyFactory—it tries to create
one of every type that implements IDummyFactory.
There's really no reason for it to though, and the indiscriminate catch
usually hides the exception, but if you're breaking on first chance
exceptions, I guess that would make the difference. Whether this is the
problem that everyone else who chimed in on the issue was having or not, I
think it's something that should be fixed.
I'm a little leery of saying that it will fix this issue, but I'll spin
off another one.


Reply to this email directly or view it on GitHub
#33 (comment)
.

from fakeiteasy.

odyth avatar odyth commented on May 18, 2024

Tonight I started getting the same error and didn't see a fix in this thread so I just decided to delete everything and re-clone my project. I then reran my unit test and it passed no issues. I then went into debug > exceptions to turn on some of the exceptions that my app throws that i like seeing when debugging. I was being lazy so i just checked all like in the screenshot.
image

I then reran my unit test and look what pops up
image

The same error I was getting. I just unchecked the box this time and hit continue and my unit test passed just fine.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@odyth, thanks for that report. It's very interesting.
Can you tell me what version of FakeItEasy you're using? I don't suppose you can do that again and include a stack trace?
I'll try to replicate your procedure as well and see what I can learn.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Just breaking on all CLR exceptions didn't make a difference for me. Perhaps there's something specific to your calls or environment.

from fakeiteasy.

odyth avatar odyth commented on May 18, 2024

sorry for the delay i am running FakeItEasy 1.25.3, NUnit 2.6.4 and Resharper 9.2. Visual Studio 2013 Ultimate w/ Sp5 on Windows 10 Pro

A first chance exception of type 'System.MissingMethodException' occurred in mscorlib.dll
Additional information: Cannot create an instance of an interface.
StackTrace

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

after hitting continue:
Additional information: Cannot create an instance of FakeItEasy.DummyDefinition`1[T] because Type.ContainsGenericParameters is true.
StackTrace

at System.RuntimeType.CreateInstanceCheckThis()

after hitting continue again
A first chance exception of type 'System.MissingMethodException' occurred in mscorlib.dll
Additional information: Cannot create an instance of an interface.
stacktrace

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@sergyr, thanks for the extra info. It goes a long way in figuring out what's happening.
Correct me if I'm missing some of the details, but this sounds exactly like #523.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

Oops. I replied to @sergyr this morning. Should've written:

@odyth, thanks for the extra info. It goes a long way in figuring out what's happening.
Correct me if I'm missing some of the details, but this sounds exactly like #523.

from fakeiteasy.

adamralph avatar adamralph commented on May 18, 2024

Duplicate of #523

from fakeiteasy.

goblinfactory avatar goblinfactory commented on May 18, 2024

I'm confused; Firstly this does not look like a duplicate of #523 since this bug specifically refers to it occurring when you run in debug mode, secondly I don't know why this bug is marked as closed? There's nothing in the discussion thread that appears to offer any actual resolution; the closest thing to a suggested work around I could see in the discussion was to start a new project. That's obviously not practical for large production solutions. Thirdly, don't understand why this was downgraded to a P3 bug; without a fix one can't debug any unit tests that use fakeItEasy.

I'm running visual studio ultimate 2013, update 5, resharper 10.0.2 and FakeItEasy 1.25.3.0.

For me, I get the error in any unit test when running in debug mode, the exception is thrown the moment I hit any call to A.Fake<xx> e.g. var portScanner = A.Fake<IPortScan>();

Good to see there's a lot of chat and movement with this library; only recently stumbled across it, and I love the simplifications, I hope this get's sorted out.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

@goblinfactory, recent reports of the symptom that included actionable/explorable information matched #523. As I read back in the history, I saw no open complaints that we'd gotten enough information about to be able to do anything. Those factors resulted in the close.

That being said, a closed issue doesn't mean it has to stay closed. We're always happy to reopen issues when appropriate. Or to open different issues if it turns out that symptoms are similar but not exactly the same, or that causes differ. So let's see what we can do for you.

Can you provide any more details at all, since many people create fake objects in debug mode and don't have any problems. We'd like to be able to isolate something specific to your project, setup, or environment.
Could you start by including a full stack trace of your error and a complete test?
You say this happens on any unit test. Does this mean you can create a new solution and get the same behaviour? If so, could you ship one to us for us to try out?
The problem happens to you when running in "debug mode". Just to make sure we have our terminology straight, does this mean when running tests built in the debug configuration, or running under the debugger, or both? Does running a release configuration DLL or running without debugging sidestep the problem?

from fakeiteasy.

goblinfactory avatar goblinfactory commented on May 18, 2024

Hi Blair; thanks for the quick and detailed reply; I'll be able to setup a test project and give you some more details tomorrow evening, txs for connecting. re: terminology : It's an odd error, it only happens from within visual studio if I "debug" into unit test; i.e. set a breakpoint and run a unit test in debug mode inside visual studio. Running without debugging (from within visual studio resharper test runner) works without error.

Now that I know there's someone interesting in investigating the problem I can spend some effort and to document what happens, create repro-solution etc.

from fakeiteasy.

blairconrad avatar blairconrad commented on May 18, 2024

That's my big suspicion.

from fakeiteasy.

thomaslevesque avatar thomaslevesque commented on May 18, 2024

That, and Just My Code disabled

from fakeiteasy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.