vanderkleij / Smocks

Smocks is a library for mocking the normally unmockable. It can mock static and non-virtual methods and properties, amongst others.
MIT License
114 stars 26 forks source link

Operation is not valid due to the current state of the object #21

Closed davidbambridge closed 8 years ago

davidbambridge commented 8 years ago

Hi,

So i was using smock without issue a few weeks ago, but going back to it now whenever I run my tests i'm getting the above error, full text below.

I'm running version 0.6.29 against .net framework 4.5.2

Any suggestions would be great.

thanks

Result StackTrace:
Server stack trace: at Mono.Cecil.ModuleDefinition.ProcessDebugHeader() at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader) at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters) at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters) at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters) at Smocks.IL.AssemblyRewriter.Rewrite(String path) at Smocks.AppDomains.AssemblyLoaderFactory.GetLoaderForAssembly(AssemblyName assemblyName) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Smocks.AppDomains.IAssemblyLoaderFactory.GetLoaderForAssembly(AssemblyName assemblyName) at Smocks.AppDomains.AssemblyResolver.LoadAssembly(AssemblyName assemblyName) at Smocks.AppDomains.AssemblyResolver.LoadAssembly(AssemblyName assemblyName) at Smocks.AppDomains.AssemblyResolver.LoadAssembly(AssemblyName assemblyName) at Smocks.AppDomains.AssemblyResolver.OnAssemblyResolve(Object sender, ResolveEventArgs args) at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName) at Smocks.AppDomains.AppDomainContext.InvokeLambda[T](SerializableLambda1 serializableLambda, Object[] arguments) at Smocks.AppDomains.AppDomainContext.InvokeSerializableLambda[T](SerializableLambda1 serializableFunc, Object target, Object[] arguments) at Smocks.AppDomains.AppDomainContext.Invoke[T](Action1 action, T parameter) at Smocks.Smock.RunAction(Action1 action, Configuration configuration) at Smocks.Smock.Run(Configuration configuration, Action1 action) at Smocks.Smock.Run(Action1 action) Result Message: Test method XWS.Tests.StartupTests.ConfigureAuthTest threw exception: System.InvalidOperationException: Operation is not valid due to the current state of the object.

vanderkleij commented 8 years ago

Thanks for reporting. Do you have any clue what caused the code to stop working? Without any code that illustrates the problem, it'll be very hard to identify and resolve the problem. Could you try to reduce your code to a minimal, complete example that exhibits the problem?

davidbambridge commented 8 years ago

Hi, sorry for the delay in reply. It seems to have been caused by a .net update to 4.6.1. I've worked around the problem by creating a new solution an rebuilding everything. So you can ignore the issue if you want.

dm-conti commented 5 years ago

I have the same problem image I am trying with 4.6.1 and 4.5.2 GetStaticSession is a static methods that return a simple string.