无法在 WPF VB.NET 项目中设置启动对象

发布于 2024-09-12 05:30:05 字数 440 浏览 9 评论 0原文

我正在使用 VS2010 VB.NET,正在开发一个包含多个项目的解决方案。我已经在它上开发了一段时间,并试图调试从 ObservableCollection 继承的自定义类(顺便说一句,即使很明显正在调用断点行,调试时也不会加载符号),我更改了将启动项目的启动对象转移到另一个 WPF 窗口,我在该窗口中留出了几个用于调试的控件。

我立即遇到了“Sub Main”未在 中找到的情况。我尝试将启动对象更改回正常启动窗口,但现在启动对象下拉列表只有“Sub Main”,因为它是唯一的选项。我将 StartupURI 更改回 App.xaml 中,但无济于事。

还有其他人看过这个吗?

如何才能恢复使用原来的窗口?

附带说明一下,是否有某个设置会导致调试器不加载程序集的符号?我知道 DiskCollection 类正在被实例化,但构造函数上的断点总是说无法命中断点,未加载符号。

科里

I am using VS2010 VB.NET, working on a solution that has a number of projects. I have been developing on it for a while now, and in an attempt to debug a custom class inherited from ObservableCollection (which by the way would not load symbols when debugging even though it was apparent that the breakpointed line was being called), I changed the startup object for the startup project to a different WPF window which I had a couple of controls that I set aside for debugging.

Immediately I was confronted with 'Sub Main' was not found in . I tried changing the startup object back to the normal startup window, but now the Startup Object dropdown only has "Sub Main" as it's only option. I changed the StartupURI back in the App.xaml, to no avail.

Anyone else seen this?

How can I get it back to using the original window?

As a side note, is there a setting somewhere that would cause the debugger not to load symbols for an assembly? I know the DiskCollection class is being instantiated, but a breakpoint on the constructor always says Breakpoint cannot be hit, No Symbols loaded.

Cory

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

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

发布评论

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

评论(2

情释 2024-09-19 05:30:05

WPF中的启动与winform中的启动不同;它由 App.xaml 文件设置。在 xaml 模式下编辑它,您会注意到这一点:

<Application x:Class="WpfApplication6.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>

StartupUri 设置哪个表单将启动事物。

如果您希望代码启动,您可以删除 StartupUri 并执行以下操作:

Startup="Application_Startup"

然后在 App.xaml.cs 文件中提供代码,如下所示:

public partial class App : Application

    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {

        }
    }

The startup in WPF is different then in winforms; it's set by the App.xaml file. Edit that in xaml mode and you will notice this:

<Application x:Class="WpfApplication6.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>

The StartupUri sets which form will start things.

If you wanted code to kick things off instead you can remove the StartupUri and do this instead:

Startup="Application_Startup"

Then provide the code in the App.xaml.cs file like so:

public partial class App : Application

    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {

        }
    }
缱绻入梦 2024-09-19 05:30:05

显然,在“项目属性”页面中,“启用应用程序框架”设置未选中。这显然告诉编译器使用 StartupUri 属性来确定启动页面,而不是使用 main sub(或方法;此设置出现在 C# 中吗?)。

不知何故,该设置未选中,因此 Sub Main 是 StartupURI 下拉列表中的唯一选项,Windows 应用程序框架属性组被禁用,并且 app.xaml 中的 StartupUri 属性未使用。

现在我知道了...

So apparently in the Project Properties page, the Enable application framework setting was unchecked. this apparently tells the compiler to use the StartupUri attribute to determine the startup page instead of using the main sub (or method; does this setting appear in C#?).

Somehow the setting was unchecked and so Sub Main was the only option in the StartupURI dropdown, the Windows Application Framework Properties group was disabled, and the StartupUri attribute in the app.xaml was unused.

Now I know...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文