Changing C# .dll references from absolute to relative

早过忘川 提交于 2019-12-03 10:43:10

Edit the .csproj file and change the <HintPath> elements from absolute paths to relative paths.

You may also write your handler for resolving assemblies. In the simplest form it may look like this:

AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;
..
static Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args)
{
  string assemblyPath = "yourpath";
  return Assembly.LoadFrom(assemblyPath + args.Name);
}

Another option is adding entry in App.config:

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="yourpath"/>
     </assemblyBinding>
  </runtime>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!