安装后无法运行wpf应用程序? [英] cannot run the wpf application after installing ?
问题描述
大家好,
我有一个项目,其中有两个项目,一个是控制库,另一个是主项目.它可以在Vs中运行,但安装后无法正常工作..
我将All .dll放在一个文件夹中,而Exe放在另一个文件夹中,
像:
程序文件\ MyApp \ dll \
程序文件\ MyApp \ exe \
现在不起作用为什么???????
安装程序项目的此担架中的任何问题..
将链接附加到示例项目链接:示例项目
( https://skydrive.live.com/redir?resid=D54B0993343A8868!133&authkey= !ACZ_YFWN08UQQlU [ ^ ])
Hello all,
I have a project that have two projects One control library and main project . It is working in Vs but after installing it not working..
I place the All .dll in one folder and Exe in other folder ,
like :
Program Files\MyApp\dll\
Program Files\MyApp\exe\
now it not working Why ???????
any problem in this stretcher of Setup project ..
attaching a link to sample project link : Sample project
(https://skydrive.live.com/redir?resid=D54B0993343A8868!133&authkey=!ACZ_YFWN08UQQlU[^])
with regards ,
jophy
推荐答案
快速解决方案是不要将.DLL文件与.EXE分开.将它们全部放在同一个文件夹中.
当需要.DLL时,程序集解析器将在与调用它的.EXE相同的文件夹中查找(默认情况下,它将不在子文件夹中查找!)如果不存在,它将开始遍历PATH环境变量寻找它.
长答案是告诉程序集解析器在哪里探测.DLL(程序集).您将其放在应用程序的初始化代码中:
The quick solution is to NOT seperate your .DLL files from the .EXE. Put them all in the same folder.
When a .DLL is needed the assembly resolver will look in the same folder as the .EXE calling for it (by default, it will NOT look in subfolders!) If it is not there, it''ll start walking the PATH environment variable looking for it.
The long answer is to tell the assembly resolver where to probe for .DLLs (assemblies). You put this in your applications initialization code:
AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = "mySubFolderName";
指定的子文件夹必须是.EXE启动文件夹下的子文件夹,此文件夹才能正常工作:
The specified sub folder MUST be a subfolder under the .EXE launch folder for this to work:
C:\Program Files
myCompanyName
myApplicationName <-- your .EXE goes in here
DLLs <-- your .DLLs go here
在此问题的描述中,没有任何信息可用于帮助您.您可以执行以下一些步骤:
- 确保您在项目中不使用任何硬编码的路径名.在任何情况下都不会有所帮助.所有路径名都应在运行时根据数据进行计算,例如:1)条目程序集主要可执行模块(例如"\ MyApp \ exe \")的位置,2)在数据目录"中保留的所有内容的特殊目录"用户或每个用户,由
System.Environment.GetFolderPath(Environment.SpecialFolder)
返回(请参阅 http://msdn.microsoft.com/en-我们/library/14tx8hby.aspx [ ^ ], http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx [ ^ ]),3)由配置文件的数据定义,4)从用户输入获得.- 将所有异常捕获在堆栈的顶部每个线程并输出全面的异常信息,包括
Exception.Stack
递归地找到所有Exception.InnnerException
.当然,您应该确保在两者之间不阻止异常传播.这是许多初学者的大错误;根据经验,最好的异常处理方法是不捕获任何异常(除了栈顶);另一个地方是UI的主事件循环.
请参阅我过去有关异常处理的答案以获取更多想法:
我如何制作滚动条到达底部时将停止的循环 [当我运行应用程序时,例外是捕获了如何处理此问题? [扔. .then ... rethrowing [ ^ ],
错误记录和屏幕截图. [捕获异常 [在类库(dll)中处理异常 [ ^ ].- 添加日志以检查代码是否通过了应用程序逻辑的所有方面.使用
System.Diagnostics.EventLog
.请参阅:
http://msdn.microsoft.com/en-us/library/system.diagnostics. eventlog.aspx [ ^ ].- 您也可以使用调试器运行该应用程序,但是这次代替了安装.在开发代码中,将输出路径更改为make与可执行模块的安装路径相同.构建代码;现在,您的代码将替换已安装的代码,同时保持所有已安装选件的完好无损.调试代码.
In the description of this issue, there is no information we could use to help you. You can make some of the following steps:
- Make sure you do not use any hard-coded path names in the project. There are no situations when it can be helpful. All the path names should be calculated during run-time based of data, such as: 1) location of the entry assembly main executable module like "\MyApp\exe\", 2) "special directories" in the data area reserved for all users or per user, returned by
System.Environment.GetFolderPath(Environment.SpecialFolder)
(see http://msdn.microsoft.com/en-us/library/14tx8hby.aspx[^], http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx[^]), 3) defined by the data of configuration file(s), 4) obtained from user input.- Catch all exceptions in the top of the stack of every thread and output comprehensive exception information, including
Exception.Stack
and allException.InnnerException
, recursively. Of course, you should make sure that you do not block exception propagation in between; this is a big mistake many beginners do; the best exception handling, as a rule of thumb, is not catching any exceptions except on top of the stack; another place is the main event loop of the UI.
Please see my past answers on exception handling for more ideas:
How do i make a loop that will stop when a scrollbar reaches the bottom[^],
When i run an application an exception is caught how to handle this?[^],
throw . .then ... rethrowing[^],
Error Logging and Screen Shot.[^],
Catching an Exception[^],
Handling exceptions in class library (dll)[^].- Add logging to check up if the code passes all points of your application logic. Use
System.Diagnostics.EventLog
. Please see:
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[^].- You can also run the application using the debugger, but this time, in place of installation. In you development code, change the output path to make is the same as the installation path for the executable module. Build the code; now your code will replace the installed code while keeping all your installed options intact. Debug the code.
这篇关于安装后无法运行wpf应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!