ExpressionBlend exception when UserControl contains my custom control

喜欢而已 提交于 2019-12-13 04:22:41

问题


I can edit this UserControl just fine in visual studio but I get this strange exception in expression blend. Does anybody know what should I look for?

UPDATE

I wasn't able to figure how to debug/attach. I did everything as instructed by Mike but no breakpoints got hit. I did more investigation and found that most likely my issue related to themes/generic.xaml

My visual studio solution has project named Infrastructure.dll. Inside that project I have folder themes and inside I have file generic.xaml. Generic.xaml set to compile as resource. My control class lives in a same project.

I have another project named 'Module.dll' and that project references Infrastructure.dll

  1. When I open view with my control (view is from Infrastructure.dll) it works in Visual Studio but gives this error in Blend.
  2. I can drag/drop control in Blend and it would give same error. I tried to remove line where I apply template to control (template in generic.xaml) and it works.
  3. Template is good, I created it using Blend and copied to generic.xaml myself.
  4. When I create view INSIDE Infrastructure.dll and drop my control on that view - it works.

So, my conclusion is that Blend doesn't see template inside generic.xaml that lives in referenced project. How do I fix this?


回答1:


Open your project in Blend (but do not yet open the problem file). Also open your solution in Visual Studio (order of opening is not important). From Visual Studio, select Debug -> Attach to process... and select Blend.exe. Make sure you're breaking on all exceptions. Once the debugger has finished attaching and loading everything, open the problem file in Blend. The debugger should (hopefully -- hard to tell from the exception details) stop at the problem area in your code.




回答2:


Issue was definitely related to Blend's inability to read/locate generic.xaml Visual studio doesn't have this issue btw. I found workaround for now - will gladly accept another answer if I can avoid doing that..

After I add resource reference to view - everything works in Blend. This means I have to add this XAML to all my views..

<UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Infrastructure.SL;component/Themes/generic.xaml"/>
            </ResourceDictionary.MergedDictionaries> 


来源:https://stackoverflow.com/questions/8159123/expressionblend-exception-when-usercontrol-contains-my-custom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!