Tag: 调试

可以在Visual Studio的输出窗口中查看OutputDebugString的输出吗?

我正在使用C#和Visual Studio 2010。 当我使用OutputDebugString写入调试信息时,它应该出现在输出窗口中吗? 我可以在DebugView中看到OutputDebugString的输出,但我想我会在Visual Studio的Output窗口中看到它。 我看过菜单工具 ? 选项 ? 调试 ? 常规 ,输出未被重定向到立即窗口。 我还看了菜单Tools *? 选项 ? 调试 ? 输出窗口和所有常规输出设置都设置为“开”。 最后,我使用了Output窗口中的下拉列表来指定应该出现Debug消息。 如果我更改菜单工具*? 选项 ? 调试 ? 一般将输出重定向到立即窗口, OutputDebugString消息不会出现在即时窗口中。 这是我的整个测试程序: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Diagnostics; namespace OutputDebugString { class Program { [DllImport(“kernel32.dll”, CharSet = CharSet.Auto)] public static extern […]

‘System.Web.Mvc.HtmlHelper’没有名为’Partial’的适用方法

我收到此错误: 错误CS1973:’System.Web.Mvc.HtmlHelper’没有名为’Partial’的适用方法,但似乎有一个名称的扩展方法。 无法动态分派扩展方法。 考虑转换动态参数或调用扩展方法而不使用扩展方法语法。“} 从我在这里读到的Razor View引擎:表达式树可能不包含动态操作 ,因为它使用的是我正在使用Session的viewbag(?)。 这是我的网络表单: @using SuburbanCustPortal.MiscClasses @{ ViewBag.Title = “Account Screen”; } AccountScreen Customer Info @Html.Partial(“CustomerInfo”) Delivery Address @Html.Partial(“DeliveryAddress”) Delivery Info @Html.Partial(“DeliveryInfo”) Balance @Html.Partial(“AccountBalance”) @if (SessionHelper.ShowPaymentOptions || SessionHelper.ShowHistory) { Account Options @using (Html.BeginForm(“AccountScreenButton”, “Customer”, FormMethod.Post)) { @if (SessionHelper.ShowHistory && SessionHelper.ShowAccountScreenPaymentButton) { Make a Payment Display Activity } else { if (SessionHelper.ShowAccountScreenPaymentButton) […]

统一成员修饰语公共必须先于

我已经解决了这个问题,但是当事情变得更加疯狂时,我意识到尝试实现这个目标是多么愚蠢,因为它最终显然没有任何好处。 如果你有类似的问题,请随意查看这个问题,也许你会学到一两件事。 Idk¯\ _(ツ)_ /¯ 人们在我这个网站上问过这个问题,但是这些都不是同一个问题。 我确定在检查代码时我可能错过了一些东西,但我无法弄清楚它是什么。 现在Unity正在困扰我,据说我不会把公共修饰符放在正确的位置,即使它正是应该的位置,从我所看到的。 让我快点告诉你…… Unity返回给我的错误: Assets\saveFiles.cs(15,1): error CS1585: Member modifier ‘public’ must precede the member type and name 我的代码 (我在这里发布这个很长的块有点疯狂,只是忽略那些我很难删除的评论。这就是我进一步开发的时候。) using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using System.IO; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Drawing; using System.Security.Permissions; // Allows permission requests from within script. VERY IMPORTANT. using System.Security.AccessControl; // […]

设置基本游戏和调试基本问题

我试图在基本的磁贴引擎中创建一个简单的蛇游戏时遇到一些问题。 我从未使用过C#或Windows Forms,目前处于学习阶段。 我很感激从这里得到任何帮助。 int[,] level = { { 0, 0, 0, 0, 0 ,0 }, { 0, 0, 0, 0, 0 ,0 }, { 0, 0, 0, 0, 0 ,0 }, { 0, 0, 0, 0, 0 ,0 }, { 0, 0, 0, 0, 0 ,0 }, { 0, 0, 0, 0, 0 ,0 […]

如何让DebuggerBrowsable RootHidden工作?

我昨天读到了DebuggerBrowsable属性,听起来很棒,但是当我试图让它在测试中工作时,它似乎没有任何区别。 我正在使用VS 2008版本9.0.30729 1 SP,.Net 3.5 SP1,MSTest框架 [TestClass] public class TestingDebuggerBrowsable { [TestMethod] public void JustToDemonstrateDebugging() { var foo = new MyExposedClass(); foo.ToString(); // I put a breakpoint here, and debugged the test } } public class MyExposedClass { public MyExposedClass() { ShouldBeSeeingThisInMyDebugger = new List {“foo”, “bar”}; } [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public IList ShouldBeSeeingThisInMyDebugger { get; […]

如何在类的调试器中更改输出?

类的ToString()方法在调试器中输出类信息,但它具有更改用户界面(UI)输出的不幸副作用。 是否有可以在类中指定的属性?

如何调试误导性的GDI OutOfMemoryexception?

我有一个调整位图大小的函数。 这是一个“面包和黄油”操作,我只是从另一个项目复制它: private Bitmap ResizeBitmap(Bitmap orig) { Bitmap resized = new Bitmap(this.Xsize, this.Ysize, PixelFormat.Format16bppGrayScale); resized.SetResolution(orig.HorizontalResolution, orig.VerticalResolution); using (Graphics g = Graphics.FromImage(resized)) { g.DrawImage(orig, 0, 0, resized.Width, resized.Height); } return resized; } 但是,我一直在Graphics g = Graphics.FromImage(resized)上获得OutOfMemoryexception。 我知道, 当谈到GDI时,OutOfMemoryexception通常会掩盖其他问题 。 我也非常清楚我想要resize的图像并不大(据我所知)GC在离开当前范围时应该没有问题收集实例。 无论如何,我现在已经玩了一段时间它现在看起来像这样: private Bitmap ResizeBitmap(Bitmap orig) { lock(orig) { using (Bitmap resized = new Bitmap(this.Xsize, this.Ysize, PixelFormat.Format16bppGrayScale)) […]

如何调试winforms设计器

我的问题不是如何在设计时调试。 我实际上想通过设计器中可用的事件进行调试。 我知道表单有加载和其他类型的事件。 在Windows窗体设计器中是否有任何事件,如init,load等? 我通过用户控件在ASP中进行了类似的调试。 它允许我们在将用户控件添加到设计器之前查看它的输出HTML。 我知道Windows窗体和ASP是不同的,但应该有一些事件在实际渲染之前检查控件的值。 我的表格需要很长时间才能在VS设计师中打开。 所以我将一个调试器附加到VisualStudio(devenv.exe),在我的Form的InitializeComponent中设置一个断点来逐步执行它以查看问题所在。 但是,断点没有被击中。

编码的UI测试现在收到有关无法找到Newtonsoft.json的错误

我有一个简单的Coded UI测试来登录应用程序。 测试是数据驱动的,并使用来自TFS的数据。 我们正在使用服务器和代理系统上的TfsTestAgent用户(具有管理员权限)。 当我执行测试时,我看到以下错误: The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see “Troubleshooting Data-Driven Unit Tests” (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.Error details: Could not load file or assembly ‘Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The […]

如何调试linq to sql InsertOnSubmit语句?

以下代码已经开始工作了。 db.DBUsers.InsertOnSubmit(new DBUser { AllTheStuff = valuesBeyondYourWildestDreams } ); db.SubmitChanges(); 我的猜测是数据库发生了变化,提交失败,因为映射已关闭。 由于linq visualiser对我不起作用(修复它的奖励点),我想找到另一种方法来了解究竟出了什么问题以及为什么提交失败了。 更新 我试过用 db.SubmitChanges(ConflictMode.FailOnFirstConflict); 得到一个例外,但似乎提交工作。 除了数据库中没有实际的新实体。