简体   繁体   English

c# 应用程序在开发机器上工作,在非开发机器上失败

[英]c# application working on development machine, fails on non-development machine

this problem has me baffled.这个问题让我很困惑。

I'm writing an application which is supposed to take information from a form, pass it to a background worker which then a) writes the information to a local xml file and b) inserts the information into a remote MySQL database.我正在编写一个应用程序,它应该从表单中获取信息,将其传递给后台工作人员,然后 a) 将信息写入本地 xml 文件,b) 将信息插入远程 MySQL 数据库。

On my development machine, it seems to work flawlessly.在我的开发机器上,它似乎完美无缺。 The remote database is updated, the xml file is created if necessary and updated if it already exists.远程数据库已更新,xml 文件在必要时创建,如果已存在则更新。 It's working.它正在工作。

Even if I exit out of the development environment and run the release build independantly of the IDE sandbox, the code works.即使我退出开发环境并独立于 IDE 沙箱运行发布版本,代码仍然有效。

But, if I put it on another machine, the code fails and I dont understand why.但是,如果我把它放在另一台机器上,代码就会失败,我不明白为什么。

I'm currently using Visual Studio 2010 Professional on a 32 bit Windows 7 Ultimate machine.我目前在 32 位 Windows 7 Ultimate 机器上使用 Visual Studio 2010 Professional。

At the moment, I'm finding that the application is stopping at a fairly specific point, which seems to be precisely where the background worker starts doing things like accessing the file system or accessing the remote database.目前,我发现应用程序在一个相当特定的点停止,这似乎正是后台工作人员开始执行诸如访问文件系统或访问远程数据库之类的操作的地方。

The project consists of a single exe file and a dll, which has a custom control I designed in it.该项目由一个 exe 文件和一个 dll 组成,其中包含我设计的自定义控件。 The custom control is working fine, in that it shows what I want it to and returns the values I'm asking it to when I want it to, so it would seem that isn't to blame.自定义控件工作正常,因为它显示了我想要它的内容,并在我想要它的时候返回我要求它的值,所以这似乎不是罪魁祸首。

I initially thought I could be looking at a permissions problem, but running the application as administrator gets me the same response.我最初认为我可能正在查看权限问题,但以管理员身份运行应用程序得到了相同的响应。

I've been writing using version 4 of the .NET framework, however I've just downgraded that to version 3.5 in the hopes that that may help.我一直在使用 .NET 框架的第 4 版进行编写,但是我刚刚将其降级到 3.5 版,希望这可能会有所帮助。 Both the non-development machines I've tried have been up to date - or have been brought up to date by me - prior to attempting to run the application.在尝试运行应用程序之前,我尝试过的两台非开发机器都是最新的——或者我已经更新了。

I'm honestly baffled here.老实说,我在这里感到困惑。 Any suggestions would be most welcome.任何建议都将受到欢迎。

Alan艾伦

If your code fails, it most likely means there is some uncaught exception.如果您的代码失败,则很可能意味着存在一些未捕获的异常。 What you should do is to log all uncaught exceptions (and probably some of the caught too) to a file, possibly using something like log4net.您应该做的是将所有未捕获的异常(可能还有一些捕获的异常)记录到一个文件中,可能使用类似 log4net 之类的东西。

I don't think we can help you beyond that.我认为除此之外我们无法为您提供帮助。

Take a look at the event viewer of your operating system.查看操作系统的事件查看器。 Administrative Tools>Event Viewer>Windows Log>Application.管理工具>事件查看器>Windows 日志>应用程序。

I have written a live logging utility called Donsole for diagnosing the application in such conditions.我编写了一个名为Donsole的实时日志记录实用程序,用于在这种情况下诊断应用程序。 On the developer workstation, it is very easy to diagnose using the feature-rich debugger of VS.在开发者工作站上,使用 VS 功能丰富的调试器很容易诊断。 The utility app.实用程序应用程序。 helps the developers exactly in this kind of scenarios where they don't have any idea what's happening inside.在这种他们不知道里面发生了什么的情况下,可以准确地帮助开发人员。 I recommend you download the latest build and try it for yourself.我建议您下载最新版本并亲自尝试。 Explaining how to use this utility and how it works is beyond the scope of this answer, so I'd forward you to the codeplex page of the project.解释如何使用此实用程序及其工作原理超出了此答案的 scope 范围,因此我将您转发到项目的 codeplex 页面。

http://donsole.codeplex.com/ http://donsole.codeplex.com/

This is how it looks.这就是它的外观。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM