C#设置探测没有的app.config privatePath? [英] C# Set probing privatePath without app.config?

查看:2817
本文介绍了C#设置探测没有的app.config privatePath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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托管代码

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屋!

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