The following code:
IDisposable d = ...
new WeakReference<IDisposable>(d);
Has started throwing the following exception on SOME machines. What could cause this?
System.Runtime.InteropServices.COMException: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
EDIT: the machines that experience the error are running Windows Server 2008 R2. Windows Server 2012 and desktop machines running windows 7 work fine. (this is true, but I now think a different issue is the relevant difference... see below).
EDIT: as an additional note, this occurred right after updating our codebase to Entity Framework 6.1.1.-beta1. In the above code, The IDisposable is a class which wraps an EF DbContext.
EDIT: why the votes to close?
EDIT: the stack trace of the failure ends at the WeakReference<T> constructor called in the above code:
at System.WeakReference`1..ctor(T target, Boolean trackResurrection)
// from here on down it's code we wrote/simple LINQ. None of this code has changed recently;
// we just upgraded to EF6 and saw this failure start happening
at Core.Data.EntityFrameworkDataContext.RegisterDependentDisposable(IDisposable child)
at Core.Data.ServiceFactory.GetConstructorParameter[TService](Type parameterType)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Core.Data.ServiceFactory.CreateService[TService]()
at MVC controller action method
EDIT: it turns out that the machines having issues with this were running AppDynamics. Uninstalling that seems to have removed the issue.