安装后无法运行wpf应用程序? [英] cannot run the wpf application after installing ?

查看:444
本文介绍了安装后无法运行wpf应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个项目,其中有两个项目,一个是控制库,另一个是主项目.它可以在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


在此问题的描述中,没有任何信息可用于帮助您.您可以执行以下一些步骤:

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 all Exception.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆