none
Cannot create an instance of "MyUserControl1" RRS feed

  • Question

  • Issue on github: https://github.com/serilog/serilog/issues/949

    There is a problem with Xaml designer. I install Serilog in Uwp application, create custom user control, insert this control in MainPage. And when I use any object from this library in field area or in constructor of my control, the Xaml designer fails to show the MainPage.

    Even if I don't instantiate any class from Serilog in design time (for example, using Lazy class), the error occurs.

    The problem disappears if I click "Disable project code" in designer, but with this I lose some other important features. Also If I run application, everything works fine.

    Serilog project's owner doesn't know what could be the cause too. Maybe somebody knows why does it happen and how to repair it? 

    Designer exception StackTrace:
    at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.InstanceBuilderOperations.InstantiateType(Type type, Boolean supportInternal)
       at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.ClrObjectInstanceBuilder.InstantiateTargetType(ILocalInstanceBuilderContext context, ViewNode viewNode)
       at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.ClrObjectInstanceBuilder.Instantiate(ILocalInstanceBuilderContext context, ViewNode viewNode)
       at Microsoft.VisualStudio.DesignTools.UwpDesigner.InstanceBuilders.FrameworkElementInstanceBuilder.Instantiate(ILocalInstanceBuilderContext context, ViewNode viewNode)
       at Microsoft.VisualStudio.DesignTools.UwpDesigner.InstanceBuilders.UserControlInstanceBuilder.Instantiate(ILocalInstanceBuilderContext context, ViewNode viewNode)
       at Microsoft.VisualStudio.DesignTools.Designer.InstanceBuilders.LocalInstanceManager.CreateInstance(IInstanceBuilder builder, ViewNode viewNode)
    InnerException:
      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)
    InnerException:
    FileNotFoundException: Could not load file or assembly 'Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its dependencies. The system cannot find the file specified.
    
    



    • Edited by Gnitry Thursday, June 29, 2017 7:54 AM
    • Moved by Xavier Xie-MSFT Thursday, June 29, 2017 10:02 AM third-party
    Wednesday, June 28, 2017 2:57 PM

All replies

  • I have the same problem that has an InnerException of a reference that isn't related to the xaml at all.  We have a class that inherits from UserControl.  Then we have other controls that inherit from that.  If I don't inherit from that first class, then the error goes away, but it has code that we need for all the child controls.  None of these care about the reference in the InnerException.
    14 hours 33 minutes ago