I'm currently taking a programming class and learning C#. One of my assignments was to have a program run with a graphical user interface that has a text box for input, a text box for output, and a button that copies whatever number was in the "input" text box and pastes it into the output text box. For some reason the method computeBtn_Click , which was the method to read the num
我目前正在上一门编程课并学习C#。 我的一项任务是让程序运行一个图形用户界面,该界面有一个输入文本框,一个输出文本框和一个按钮,用于复制“输入”文本框中的任何数字并将其粘贴到输出中文本框。 出于某种原因,方法computeBtn_Click (它是读取输入中的数字并将其放入输出中的方法)对我来说computeBtn_Click_1 ,但是通过使用方法名称computeBtn_Click_1它运行得非常好。 任何想法为什么? 这是我的代码(没有使用所有
I have the following blocks of code: Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(this.pathToFile); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; I push the xlRange into an array using: someArray = (System.Object[,])xlRange.Value2; Afterwards I try to cleanup with: M
我有以下代码块: Excel.Application xlApp = new Excel.Application(); Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(this.pathToFile); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRange = xlWorksheet.UsedRange; 我使用以下命令将xlRange推入一个数组中: someArray = (System.Object[,])xlRange.Value2; 之后,我尝试使用以下方式进行清理: Marshal.ReleaseComOb
Experts, I am facing one issue in Windows Application during button click. I have two files A.cs & B.cs In A.cs file I have a button called "Load" and when I click this button I need to trigger a function in B.cs. To do this, I have written a Event Handler. Common File: public delegate void MyEventHandler(object sender, EventArgs e, string TagId); A.cs file: public e
专家介绍, 点击按钮时,我正面临Windows应用程序中的一个问题。 我有两个文件A.cs&B.cs 在A.cs文件中,我有一个名为“Load”的按钮,当我点击这个按钮时,我需要在B.cs.中触发一个函数。 为此,我写了一个事件处理程序。 通用文件: public delegate void MyEventHandler(object sender,EventArgs e,string TagId); A.cs文件: 公共事件MyEventHandler OnTagLoad; private void btnLoad_Click(object sen
I am trying to save an excel file that was created and written to via a C# application using the Excel Interop. I have looked all over this site as others to find a code that properly works and I have yet to find one. My excel interop funciton uses a workbook, worksheet, app, and workshee_range object. Does anyone have any suggestions. The easier the solution the better. I'm a beginner t
我试图保存一个使用Excel Interop通过C#应用程序创建和写入的Excel文件。 我已经遍寻这个网站作为其他人找到一个适当的代码,我还没有找到一个。 我的excel interop funciton使用工作簿,工作表,应用程序和workshee_range对象。 有没有人有什么建议。 解决方案越容易越好。 我是初级到中级C#程序员,高级解决方案可能超出我的知识范围。 在保存并关闭excel文件后,尝试断开与excel interop的连接时出现未处理的异常,说
I have an application that uses COM interop to create a spreadsheet which is opened in Excel on the client's machine. It appears, however, that the EXCEL.exe process isn't always ended when Excel is closed by the user if I look at Task Manager. If I was saving the workbook and programmatically closing Excel, I would just use Marshal.ReleaseComObject() to clean up, but since I'm dep
我有一个应用程序使用COM互操作来创建电子表格,该电子表格在客户机的Excel中打开。 但是,看起来,如果我查看任务管理器,用户关闭Excel时EXCEL.exe进程并不总是结束。 如果我保存工作簿并以编程方式关闭Excel,我只需使用Marshal.ReleaseComObject()进行清理,但由于我依赖于程序的手动关闭,所以我不知道该怎么做。 有什么建议么? 直到所有它的进程外对象被释放后,Excel才能终止。 所以它只是隐藏其用户界面并继续运
Hey everyone, I've been reading about a lot of people finding it hard to close instances of a running excel application created using Com objects. I've managed to sporadically cause Excel instances to be completely closed however not all the time (I'll get to this later). My problem is rather more complex than simply closing a running instance of Excel as I am trying to create an a
嗨,大家好,我一直在阅读很多人发现很难关闭使用Com对象创建的正在运行的Excel应用程序的实例。 我设法零星地让Excel实例完全关闭,但不是所有的时间(我将在后面讨论)。 我的问题比简单地关闭正在运行的Excel实例要复杂得多,因为我正在尝试创建一个应用程序: 使用许多可用模板之一创建一个Excel文件(这可以很好地工作) 根据我的应用中选择的条件填充模板的单元格(也可以正常工作) 允许用户继续输入无法从我的
I'm using the Excel interop in C# ( ApplicationClass ) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); Although this kind of works, the Excel.exe process is still in the background even after I close Excel. It is only released once my
我在C#中使用Excel interop( ApplicationClass ),并在我的finally子句中放置了下面的代码: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); 虽然这种工作, Excel.exe进程仍然在后台,即使我关闭了Excel。 只有在我的应用程序被手动关闭时才会被释放。 我做错了什么,或者有没有其他方法可以确保互操作对象
This one really has me stumped. I'm working with another developer who called me because he couldn't believe what he was seeing. We stepped through with the debugger together and I saw it too and had no explanation. Here's the scenario. He is writing a method that interacts with a 3rd party COM object through an auto-generated COM wrapper (generated simply by adding the COM compon
这真的让我难住了。 我正在和另一位打电话给我的开发者合作,因为他无法相信他所看到的。 我们一起调试了一下,我也看到了,没有任何解释。 这是场景。 他正在编写一种方法,通过自动生成的COM包装器(通过将COM组件添加为引用而生成)来与第三方COM对象进行交互。以下是他的方法的顶部: public bool RefolderDocument(ref IManDocument oDoc) { string strCustom1 = (string) oDoc.GetAttributeValueByID(im
Given: DateTime.UtcNow How do I get a string which represents the same value in an ISO 8601-compliant format? Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is: yyyy-MM-ddTHH:mm:ssZ DateTime.UtcNow.ToString("yyyy-MM-ddTHH\:mm\:ss.fffffffzzz"); This gives you a date similar to 2008-09-22T13:57:31.2311892-04:00 . Another way is: DateTime.UtcNo
鉴于: DateTime.UtcNow 我如何获得一个代表符合ISO 8601标准格式的相同值的字符串? 请注意,ISO 8601定义了许多类似的格式。 我正在寻找的具体格式是: yyyy-MM-ddTHH:mm:ssZ DateTime.UtcNow.ToString("yyyy-MM-ddTHH\:mm\:ss.fffffffzzz"); 这会给你一个类似于2008-09-22T13:57:31.2311892-04:00的日期 。 另一种方法是: DateTime.UtcNow.ToString("o"); 这给你2008-09-22T14:01:54.9571247Z 要获得指定
This question already has an answer here: Globally catch exceptions in a WPF application? 6 answers You can handle the AppDomain.UnhandledException event EDIT: actually, this event is probably more adequate: Application.DispatcherUnhandledException You can trap unhandled exceptions at different levels: AppDomain.CurrentDomain.UnhandledException From all threads in the AppDomain. Disp
这个问题在这里已经有了答案: 在WPF应用程序中全局捕获异常? 6个答案 您可以处理AppDomain.UnhandledException事件 编辑:实际上,这个事件可能更充足: Application.DispatcherUnhandledException 您可以在不同级别捕获未处理的异常: AppDomain.CurrentDomain.UnhandledException所有线程。 Dispatcher.UnhandledException从一个特定的UI调度程序线程。 Application.Current.DispatcherUnhandledException从