开发者

VB.NET app works in IDE but throws an error when compiled and run on another machine

I have created an application using VB.NET in VS2008. When I run the app in the IDE on my development machine it works fine. It also works fine when I build it and run it as an exe on any machine that also has Visual Studio installed (at least 2005 and 2008 anyway) However, when I try to开发者_开发百科 run the compiled executable on any machine without Visual Studio it throws up an error "[program name] has encountered a problem and will close..."

Does anyone have any thoughts on this.

Thanks


It is possible that you have libraries in your GAC that are not present on machines that don't have visual studio installed. Check what libraries you are referencing and try adding dlls directly to your project.


I'll ask the proverbial "Is is plugged into the wall?" question: Does your target machine have the .Net framework installed? VB.Net programs require that the .Net framework runtime is installed to function.


The error message you describe is a memory violation of some sort. But there's too little information to identify what the problem is.

To identify the problem, write a "hello world" program and see if you can reproduce the error. Include all of your using statements. If it still fails, I would make sure that all of the necessary libraries are available on your target machine. You can put them into the same folder as your executable for testing purposes.

If that goes OK, you should start blocking out parts of the code to prevent them from executing (either by commenting them out or using return statements), and attempt to reproduce the problem. When the problem goes away, the last block of code that you commented out is the one with the error.


You can run a reflector at the EXE on the PC without VS installed. It can tell you the dependent assemblies and whether you can check if you have them on that system.


There are a ton of reasons that the app could crash like

  • missing a resource/config file
  • the target machine might not have the necessary version of the .Net framework
  • the app could be compiled for amd64 and you're trying to run it on an x86 machine
  • your app doesn't have permission to do something (like read from HKLM) and doesn't handle that

Getting the actual error/exception message would be much more helpful to figure out why the app is crashing.

Try adding a catch-all exception handler which could pop-up an alert box with the exception text/stack trace or installing windbg as the interactive debugger and capturing a dump or running the app under the debugger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜