-3

First of all, sorry for my bad english. I post here because I know some people have very relevant answers.

I've been working on a WPF application for several months without any problem. Since this morning, everytime I try to click, update or resize an element in the designer, an exception occurs and I must reload the designer every 10s.

This is kind of annoying and I really can't figure out how to resolve this.

Here is the error :

System.ArgumentNullException
La valeur ne peut pas être null.
   à System.RuntimeType.MakeGenericType(Type[] instantiation)
   à Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.GetRuntimeType(Type type)
   à Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkType.TryGetRuntimeType()
   à Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUtil.EnsureRuntimeType(Type type)
   à Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.GetRuntimeType(Type reflectionType)
   à MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeType(Type reflectionType)
   à Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeType(Type reflectionType)
   à Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeType(Type reflectionType)
   à MS.Internal.Metadata.ClrType.get_RuntimeMember()
   à MS.Internal.Metadata.ClrMember`1.Microsoft.Windows.Design.Metadata.Reflection.IReflectionMember.get_MemberInfo()
   à MS.Internal.Metadata.ClrType.Equals(Object obj)
   à System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)
   à System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   à System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   à Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.<>c__DisplayClass5.<FindAttachableProperties>b__4(ITypeMetadata walkType)
   à MS.Internal.Design.Metadata.Xaml.XamlType.<GetAllAttachableProperties>d__7.MoveNext()
   à MS.Internal.Design.Metadata.Xaml.XamlType.<FindAttachableProperties>d__0.MoveNext()
   à Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.<FindAttachableProperties>d__7.MoveNext()
   à MS.Internal.VirtualModel.VirtualModelPropertyCollection.<GetUncachedProperties>d__0.MoveNext()
   à System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   à System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   à MS.Internal.VirtualModel.VirtualModelPropertyCollection.GetEnumerator()
   à MS.Internal.VirtualModel.VirtualModelUtilities.WrapProperties(IVirtualModelItem item)
   à MS.Internal.VirtualModel.VirtualModelItem.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
   à System.ComponentModel.TypeDescriptor.MergedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
   à System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)
   à System.Windows.PropertyPath.ResolvePropertyName(String name, Object item, Type ownerType, Object context, Boolean throwOnError)
   à MS.Internal.Data.PropertyPathWorker.GetInfo(Int32 k, Object item, SourceValueState& svs)
   à MS.Internal.Data.PropertyPathWorker.ReplaceItem(Int32 k, Object newO, Object parent)
   à MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   à MS.Internal.Data.ClrBindingWorker.AttachDataItem()
   à System.Windows.Data.BindingExpression.Activate(Object item)
   à System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   à System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
   à System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
   à System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   à System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   à System.Windows.Data.BindingOperations.SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
   à System.Windows.FrameworkElement.SetBinding(DependencyProperty dp, BindingBase binding)
   à MS.Internal.GridControl.GridChildMarginAdorner.SetDragBinding(ModelItem source, Boolean dragging)
   à MS.Internal.GridControl.GridChildMarginAdornerProvider.ChildMarginAdornerPanel.CalcLayout(Boolean measure)
   à MS.Internal.GridControl.GridChildMarginAdornerProvider.ChildMarginAdornerPanel.MeasureOverride(Size availableSize)
   à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   à System.Windows.UIElement.Measure(Size availableSize)
   à MS.Internal.Interaction.BaseAdornerLayout.Measure(UIElement adorner, Size constraint)
   à MS.Internal.Interaction.AdornerLayer.MeasureOverride(Size constraint)
   à System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   à System.Windows.UIElement.Measure(Size availableSize)
   à System.Windows.ContextLayoutManager.UpdateLayout()
   à System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   à System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   à System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   à System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   à System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Thank you for your help.

Chostakovitch
  • 965
  • 1
  • 9
  • 33
  • Google translate says `La valeur ne peut pas être null` means `Value can not be null`. Looks like your project can no longer determine a type, check to see if something has been removed. It would be helpful to post the source code where the exception is occurring. – SwDevMan81 Dec 22 '14 at 14:20
  • @SwDevMan81 Thank you for your answer. The application is a huge project and the error seems to occur in all the files, in the designer. I don't think that the problem comes from the code (the program compiles and runs perfectly, without any exception), that's why I can't understand this error. – Chostakovitch Dec 22 '14 at 14:24
  • 1
    Do you have a backup copy of your files? It seems that something is gone haywire in your project files. – Steve Dec 22 '14 at 14:25
  • I'd try @Steve's advice first, try and build a backup copy, then try a different PC (maybe image is corrupt) if that doesnt work. – SwDevMan81 Dec 22 '14 at 14:27
  • Also, sometime using BUILD->Clean Solution could help – Steve Dec 22 '14 at 14:28
  • I think you might be using a style in some controls using `{StaticResources KEY}` and the key is probably in the main dictionnary, most likely `app.config` and you might not have it anymore or you might have changed or removed an essential `TargetType=XXXXXX` on it – Franck Dec 22 '14 at 14:37
  • @Steve, I haven't a backup copy but it seems that all people who work on this project have the same problem. In fact, the application is divided in 11 projects, and this occurs in several of theses projects. I tried to clean and generate, but it changes nothing. – Chostakovitch Dec 22 '14 at 14:50
  • @Frank, thank you for you answer. The only StaticResource I use is a template, which is well defined. – Chostakovitch Dec 22 '14 at 14:51
  • try to copy it local to the windows (resource of the window itself) and see if this works. If you still have the issue make sure you have .net 4.5 installed. i had the same issue with most windows inside sub project dll using styles/templates from my main project and installing .net 4.5 even though we only use 4.0 it fixed the issue. – Franck Dec 22 '14 at 14:55
  • I would also review the `Remarks` section in [Type.MakeGenericType Method](http://msdn.microsoft.com/en-us/library/system.type.makegenerictype%28v=vs.110%29.aspx) and make sure any of the rules mentioned were not violated recently. Since you dont have a backup copy, this will be hard but maybe it will ring some bells. Also check and see if any recent parameterless constructors where changed to take parameters (sometimes reflection requires a parameterless constructor). – SwDevMan81 Dec 22 '14 at 15:03
  • @Franck, i tried to uninstall .net 4.0 and reinstall it, repair Visual Studio and Telerik. Seems like the problem is solved. Thanks for all your answers ! – Chostakovitch Dec 23 '14 at 09:46

2 Answers2

0

Try this, it might help and give you more information about the cause of the exception:

  • start Visual Studio and open your project
  • start another instance of Visual Studio without opening any project in it
  • in the second instance go to DEBUG > Attach to Process... and select the first instance of Visual Studio where your project is opened
  • now still in the second instance go to DEBUG > Exceptions... and check the Thrown next to Common Language Runtime Exceptions

If the exception now occurs the other VS should catch it so that you can hopefully browse it and see the details (like the exception message or the affected property etc.).

t3chb0t
  • 16,340
  • 13
  • 78
  • 118
0

I eventually solved my problem by uninstalling and reunstalling .NET 4.0, Visual Studio and Telerik. Seems like Telerik references are hard to manage.

Thank you for your answers !

Chostakovitch
  • 965
  • 1
  • 9
  • 33