调用位于另一个目录中的DLL文件 [英] Call DLL files located in another directory

查看:382
本文介绍了调用位于另一个目录中的DLL文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台应用程序( NGameHost )在一个特定的目录下运行( C:\\ Program Files文件\\ NetworkGame3 \\ API \\ )。它使用现有的文件在该目录中,并在其自己的运行控制台应用程序运行良好。这也暴露了从该目录中使用的DLL(和其他文件,如配置文件)的各种方法。我现在有一个试图调用这些方法并返回结果的另一个控制台应用程序(位于其他地方)。我给自己定复制本地:假,以便它的目录,而不是创建一个本地版本中执行。不过,我得到的错误无法加载文件或程序...或者它的一个依赖该系统找不到指定的文件。

I have a console application (NGameHost) running in a specific directory (C:\Program Files\NetworkGame3\api\). It uses the files available in that directory and the console application works well when run on its own. It also exposes various methods that use the DLLs (and other files such as config files) from that directory. I now have another console application (located elsewhere) that tried to call those methods and return the results. I've set Copy Local: False so that it executes within that directory instead of creating a local version. However I get the error "Could not load file or assembly ... or one of its dependencies. The system cannot find the file specified."

我怎么能调用的方法从位于另一个目录中的控制台应用程序?

How can I call the methods from a console application located in another directory?

推荐答案

当您设置复制本地= FALSE你的意思是,不要将程序集复制到本地目录在这种情况下,大会将提供之一地方运行时查找它。

When you set copy local = false what you're saying is that do not copy the assembly to the local directory in which case assembly will available in one of the places where the runtime looks for it.

请参阅运行时如何定位组装

您组件必须要么在GAC或在探测位置之一

Your assembly has to be either in GAC or in one of the probing locations.

这篇关于调用位于另一个目录中的DLL文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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