阻止 Blend 添加startupURI 到应用程序?

发布于 2024-09-24 08:00:30 字数 470 浏览 1 评论 0原文

是否有一些已知的技巧可以告诉 Blend 停止尝试在我的 app.xaml 中设置startupURI?我用谷歌搜索但没有看到任何东西所以我想我会在这里问。

我使用启动例程并自己实例化主窗口。每隔一段时间,当我让它编译时,blend 就会加入startupURI="MainWindow.xaml"。有时我会看到一些类似“没有与该项目相关的启动场景。您想混合到等等修复它吗?”之类的消息。或者类似的东西。我单击“取消/否”,但它仍然在我的代码中抛出一个小精灵。在混合内部有一些机制来检查此属性,否则它不会通过对话框向我抱怨。那么我该如何告诉它“不,谢谢混合,没有它我也很好?”,哈哈。

这很烦人。我打开 Blend 来做一些简单的事情,比如使用颜色选择器并用它来编译,因为 VS2010 没有打开。我的结果是两个主窗口。但它并不是每次都会这样做,所以这不是一个可重复的行为。编译器只是随机执行。

编辑:我正在使用 Blend 4,但我在使用 Blend 3 时也看到了这种情况。

Is there some trick that is known to tell blend to stop trying to set a startupURI in my app.xaml? I googled but didn't see anything so I figured I would ask here.

I use a startup routine and instantiate mainwindow myself. Every once and a while blend likes to toss in the startupURI="MainWindow.xaml" when I let it compile. Occasionally I see some message along of the lines of "There is no startup scene associated with this project. Would you like blend to blah blah fix it?" or something along those lines. I click cancel/no yet it still tosses a gremlin in my code. Internal to blend there is some mechanism for checking for this property or it wouldn't complain via dialog box to me. So how do I just tell it "no thanks blend, i'm good without that?", lol.

Its quite annoying. I open blend to do something simple like using a color picker and use it to compile because VS2010 isn't open. My result is two mainwindows. But it does not do it every time so it's not a repeatable behavior. The compiler just acts out randomly.

edit: I'm using blend 4 but I saw this happen when i was using blend 3 also.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

始终不够 2024-10-01 08:00:30

这是一个非常非常可怕的黑客攻击,但是嘿,它确实有效。默认情况下,StartupUri 为 null,但您无法使用该属性将其设置为 null,因此如果您喜欢生活在边缘,则可以绕过该属性。

// Dangit blend! Stop inserting a stupid StartupUri    
private void FixStartupUri()
{
    var type = typeof(Application);
    var startupUri = type.GetField("_startupUri", BindingFlags.Public
        | BindingFlags.NonPublic
        | BindingFlags.Instance);
    startupUri.SetValue(this, null);
}

将其添加到您的应用程序类中并像这样调用它:

protected override void OnStartup(StartupEventArgs e)
{
    FixStartupUri();
    base.OnStartup(e);
    // Do the rest of your startup stuff.
}

This is a horrible, terrible hack, but hey, it works. By default, StartupUri is null, but you can't set it to null using the property, so you can go around the property if you like to live on the edge.

// Dangit blend! Stop inserting a stupid StartupUri    
private void FixStartupUri()
{
    var type = typeof(Application);
    var startupUri = type.GetField("_startupUri", BindingFlags.Public
        | BindingFlags.NonPublic
        | BindingFlags.Instance);
    startupUri.SetValue(this, null);
}

Add this to your Application class and call it like so:

protected override void OnStartup(StartupEventArgs e)
{
    FixStartupUri();
    base.OnStartup(e);
    // Do the rest of your startup stuff.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文