C# 在没有 app.config 的情况下设置探测 privatePath? [英] C# Set probing privatePath without app.config?
问题描述
我有一个 C# 应用程序,为了组织它的文件,我在名为Data"的文件夹中有一些 DLL.我希望 EXE 检查此文件夹中的 DLL,就像它检查其当前目录的方式一样.如果我使用此信息创建了 App.Config:
I have a C# application, and to organize its files I have some DLL's in a folder called "Data". I want the EXE to check this folder for the DLL's just like how it checks its current directory. If I created a App.Config with this information:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Data" />
</assemblyBinding>
</runtime>
</configuration>
它可以正常工作.我不想有 App.Config.有没有办法在不使用 app.config 的情况下设置探测路径?
It works without a problem. I do not want to have an App.Config. Is there a way to set the probing path without using an app.config?
推荐答案
您可以为您创建的新 AppDomain 执行此操作,我认为没有办法在当前/默认 AppDomain 的托管代码中执行此操作.
You can do it for new AppDomains you create, I don't believe there is a way to do it in managed code for current/default AppDomain.
>
使用私有路径创建 AppDomain:使用 AppDomain.CreateDomain和 AppDomainSetup.PrivateBinPath
Creating AppDomain with private path: use AppDomain.CreateDomain and AppDomainSetup.PrivateBinPath
这篇关于C# 在没有 app.config 的情况下设置探测 privatePath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!