Binding Text property with ApplicationBarIconButton in WP7 - windows-phone-7

I want to bind the string to Text Property in ApplicationBarIconButton in WP7.
While doing this, I got an error as
Set property 'Microsoft.Phone.Shell.ApplicationBarIconButton.Text' threw an exception.
StackTrace:
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.RuntimePropertyInfo.InternalSetValue(PropertyInfo
thisProperty, Object obj, Object value, Object[] index,
StackCrawlMark& stackMark)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)
at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType,
XamlQualifiedObject& inObj, XamlPropertyToken inProperty,
XamlQualifiedObject& inValue)
at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr
pContext, IntPtr pComponent, UInt32 cUriStringLength, String
uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32
cAssemblyStrLength, String assemblyStr)
at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase
componentAsDO, String resourceLocator, UnmanagedMemoryStream stream,
UInt32 numBytesToRead, String assemblyString)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Syncfusion.Phone.Tools.Controls.TimeSpanPickerPage.InitializeComponent()
at Syncfusion.Phone.Tools.Controls.TimeSpanPickerPage..ctor()
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo
rtci, BindingFlags invokeAttr, Binder binder, Object parameters,
CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean
verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Activator.InternalCreateInstance(Type type, Boolean nonPublic, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type)
at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback
userCallback, PageResourceContentLoaderAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.<>c_DisplayClass4.b_0(Object
args)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo
rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object
parameters, CultureInfo culture, Boolean isBinderDefault, Assembly
caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority
priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle,
Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
Solution: The ApplicationBar is a special element that is not implemented in Silverlight and cannot be used with databinding. You'll have to directly update the Text property in C#. Peter Torr explains it here: Peter Torr's Blog > Why are the ApplicationBar objects not FrameworkElements?

It seems to me you already know the answer, anyhow binding data the ApplicationBar is not possible, you can create the application bar at runtime though, you might be able to do something from there. ApplicationBarIconButton At Runtime

Although the ApplicationBar is not a bindable object, there are workarouds to make binding work.
One, is the ApplicationBarBehavior from the Cimbalino Windows Phone Toolkit (you can get it from NuGet)!

Related

Internal error when running visual studio project

I'm building a WPF application that currently only has UI elements in place. I'm trying to use some classes I made in another project by importing a dll. When I run the wpf application, Visual Studio pops up this dialog in the Team Explorer:
The application still runs, but I don't know the cause of this error and what its effects are. Has anyone else run into this error and have some insight?
Not sure if it is relevant, but the project I'm importing is using NHibernate and Log4Net. I'm also using Visual Studio 2013 Express if that has anything to do with it.
UPDATE:
Here's the stack trace:
at DatabaseUI.DatabaseViewModel..ctor() in c:\Users\andrew\Documents\Visual Studio 2013\Projects\DatabaseUI\DatabaseUI\ViewModels\DatabaseViewModel.cs:line 36
at DatabaseUI.MainWindow..ctor() in c:\Users\andrew\Documents\Visual Studio 2013\Projects\DatabaseUI\DatabaseUI\MainWindow.xaml.cs:line 30
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)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at System.Xaml.Schema.SafeReflectionInvoker.CreateInstanceCritical(Type type, Object[] arguments)
at System.Xaml.Schema.SafeReflectionInvoker.CreateInstance(Type type, Object[] arguments)
at System.Xaml.Schema.XamlTypeInvoker.CreateInstance(Object[] arguments)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstanceWithCtor(XamlType xamlType, Object[] args)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)
at System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
at System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at DatabaseUI.App.Main() in c:\Users\andrew\Documents\Visual Studio 2013\Projects\DatabaseUI\DatabaseUI\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
UPDATE 2:
I removed the ViewModel code because this problem existed before I created it. I got this error when I first created a wpf application without any content. I'm looking for answers that describe what this error means or a similar situation that someone had where they were able to resolve this issue.
UPDATE 3:
I started a new console application project and I'm getting the same error. This project does not use any resources from the previously described project, but both of these projects use log4net and nhibernate. I think this is an nhibernate issue.
UPDATE 4:
I started a new console application with absolutely nothing to it, and I'm still getting this error. I've deleted all references and the entire AssemblyInfo.cs, and still no progress.
UPDATE 5:
I create a new C++ console application and I am getting the same error. No nhibernate or anything that I thought was messing it up. There is definitely something wrong with Visual Studio...
Well, I fixed the error by re-installing Visual Studio. I'm still looking into what exactly went wrong, but something deep in the depths of Visual Studio must have been corrupted. Once I know more, I will update this answer to be more complete.
This happens when you have a static resource, in your case is databseviewmodel that is getting initiated and failure is due to that. If your viewmodel is calling database when it is constructed then it will show error due to improper initialization.

xunit cannot discover tests after upgrading to v2

After upgrading to xunit2 and following the migration guide (http://xunit.github.io/docs/test-migration.html), I get the following error when discovering tests in my projects:
------ Discover test started ------
[xUnit.net 00:00:00.0701819] Exception discovering tests from MyLibrary.Tests.dll: System.MissingMethodException: Constructor on type 'Xunit.Sdk.TestFrameworkProxy' not found.
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at Xunit.RemoteAppDomainManager.CreateObject[TObject](String assemblyName, String typeName, Object[] args)
at Xunit.Xunit2Discoverer..ctor(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, String assemblyFileName, String xunitExecutionAssemblyPath, String configFileName, Boolean shadowCopy, String shadowCopyFolder)
at Xunit.XunitFrontController.CreateInnerController()
at Xunit.XunitFrontController.get_InnerController()
at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.DiscoverTests[TVisitor](IEnumerable`1 sources, IMessageLogger logger, Func`3 visitorFactory, Action`3 visitComplete, Stopwatch stopwatch)
========== Discover test finished: 0 found (0:00:00.2454142) ==========
I have no experience debugging testrunners or xunit, so I don't know where to look. I hope someone has encountered the problem before and can give a quick answer, but my google-fu shows nothing.
I don't know what information would be useful for tracking down this problem, so I'll add things as people ask for them.
From the test runner documentation: If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio.
Deleting %TEMP%\VisualStudioTestExplorerExtensions seems to fix the issue.
Ref.: http://xunit.github.io/docs/running-tests-in-vs.html
Make sure you have installed both Xunit and Xunit.Runner.VisualStudio nuget packages

HttpWebRequest not working on device

I have read some topics that contains that problem but none of the answer was useful or topic wasn't resolved at the end.
So my app is working fine on emulator but doesn't work on device (HTC Trophy it that matters somehow?). I'm catching exception like that:
System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass2.<EndGetResponse>b__1(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.Dispatcher.<>c__DisplayClass4.<FastInvoke>b__3()
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at Birdaholic1.AddSighting.GetResponseCallback(IAsyncResult asynchronousResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.<InvokeGetResponseCallback>b__8(Object state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()
What should I do? Where should I start to fix it?
Checklist for things to look at:
is the URI-object set with the UriKind.Absolute attribute?
does my cell phone have a data connection (i.e. does other apps like Facebook, internet explorer work)?
if so, can I open the URL in the web browser (given it's a GET-request) and find it?
If the answer is yes to all those questions, try with a second device if at all possible and try to recreate the problem. If it still persists, look at the server side of things, perhaps caching is screwing you up for some reason.
Happy (bug) hunting!

Constructor on type 'System.Web.Mvc.WebFormView' not found

I just checked out a asp net mvc project from out TFS. After installing all required NuGet packages, I tried to run the project.
I keep getting this error message when trying to use one of the following methods of the MvcSiteMapProvider:
SiteMapTitle()
SiteMap()
SiteMapPath()
I am using .NET Framework 4.0, MVC3 and the MvcSiteMapProvider version 3.2.2.0.
I installed the MvcSiteMapProvider via NuGet (Package Manager Console).
my project references the DLL in ...\packages\MvcSiteMapProvider.3.2.2.0\lib\net40\MvcSiteMapProvider.dll, using Runtime Version v2.0.50727
[MissingMethodException: Constructor on type 'System.Web.Mvc.WebFormView' not found.]
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Activator.CreateInstance(Type type, Object[] args) +19
MvcSiteMapProvider.Internal.MvcSiteMapProviderViewEngine.CreatePartialView(ControllerContext controllerContext, String partialPath) +109
System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) +217
System.Web.Mvc.<>c__DisplayClass8.<FindPartialView>b__7(IViewEngine e) +21
System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +127
System.Web.Mvc.ViewEngineCollection.FindPartialView(ControllerContext controllerContext, String partialViewName) +170
System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions) +418
System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate) +1117
System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData) +66
System.Web.Mvc.Html.TemplateHelpers.TemplateFor(HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData, TemplateHelperDelegate templateHelper) +117
System.Web.Mvc.Html.TemplateHelpers.TemplateFor(HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData) +100
System.Web.Mvc.Html.DisplayExtensions.DisplayFor(HtmlHelper`1 html, Expression`1 expression, String templateName) +57
MvcSiteMapProvider.Web.Html.SiteMapTitleHelper.SiteMapTitle(MvcSiteMapHtmlHelper helper, String templateName) +412
MvcSiteMapProvider.Web.Html.SiteMapTitleHelper.SiteMapTitle(MvcSiteMapHtmlHelper helper) +33
ASP._Page_Views_Shared__Layout_cshtml.Execute() in xxx\Views\Shared\_Layout.cshtml:28
Any help would be appreciated.
Try to update to version 3.2.3, then it should work.

Interface not registered(0x80040155) when running Pex On Specific machine

Pex 0.94.0.0 Release Visual Studio 10.0.40219.1 Bug Report
How to reproduce:
Open a class library project
Create an empty method
Right Click->Run Pex
I run without problem on another machine (In Office, VS2010 Utimate)
But I got this exception on my home computer(VS2010 Professtional)
exception details:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.DTE'.
This operation failed because the QueryInterface call on the COM component for the interface with IID
'{04A72314-32E9-48E2-9B87-A63603454F3E}') failed due to the following error: Interface not registered.
(Exception from HRESULT: 0x80040155)
at Microsoft.Pex.VsPackage.VsServiceProviderHelper.GetService[T](IServiceProvider serviceProvider)
at Microsoft.Pex.VsPackage.Helpers.ProjectHelper.SaveAllFiles(IServiceProvider serviceProvider)
at Microsoft.Pex.VsPackage.Actions.ActionComponent.SaveAll()
at Microsoft.Pex.VsPackage.Actions.ExplorationActionBase.InternalExecute()
at Microsoft.Pex.VsPackage.Actions.ActionComponent.Execute(Object target)
Current stacktrace
at Microsoft.Pex.VsPackage.Controls.ErrorReport.CreateReport(Exception ex)
at Microsoft.Pex.VsPackage.Controls.ErrorReport.<>c_DisplayClass4.b_3()
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Microsoft.Pex.VsPackage.Helpers.UIThreadInvoker.SafeMethodInvoker.Invoke()
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
relevant environment variables:
COR_ENABLE_PROFILER=
COR_PROFILER=
PROCESSOR_ARCHITECTURE=x86
machine data:
processor count = 4
Turns out to be some weird registry problem
Reinstalling Windows can solve it

Resources