引用的程序集与项目输出的路径不同 [英] Referenced assemblies in different path than project output

查看:69
本文介绍了引用的程序集与项目输出的路径不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我引用的程序集有问题.
总的来说,我有很多参考资料,但我不想将它们复制到项目输出文件夹中.

我的文件夹结构如下所示:

Hello folks,

I''ve got a problem with referenced assemblies.
In general I have a lot of references and I don''t want them to be copied to the project output folder.

My folder structure looks like this:

- Build
  - 3rdParty
  - Common
  - Plugins



我要将可执行文件放在根文件夹(生成")中.所有第三方程序集均应位于文件夹"3rdParty"中.我在Common文件夹中写的所有库,所有插件都相同(我使用MEF).

插件运行良好.没问题.
与文件夹"Common"相同.我只是在相应项目的项目属性中将输出路径设置为文件夹"Common",并在引用程序集的属性中设置相应的引用路径.

但是我遇到了第三方库的问题.
我像往常一样添加了它们,作为对我的项目的参考.然后,我调用了该引用的相应属性页,并将Copy to local folder设置为false.之后,我在解决方案中创建了一个名为"3rdParty"的子文件夹.在那里,我将所有第三方程序集都添加为Content,并且Copy to output directory设置为Always copy.

另外,我在解决方案中添加了app.config.
内容,我想这是错误的:)



I want my executable in the root folder (Build). All third-party assemblies shall be located in the folder ''3rdParty''. All libraries I wrote myself in the folder ''Common'', same for all plugins (I''m using MEF).

Plugins is working well. No problem here.
Same for folder ''Common''. I just set the output path in the project properties of the according project to folder ''Common'' and in the properties of the referencing assembly I set the according reference path.

But I ran into problems with the 3rd party libraries.
I added them as usual as reference to my project. Then I called the according property page of that reference and set Copy to local folder to false. Afterwards I''ve created a sub-folder in my solution called ''3rdParty''. There I''ve added all the 3rd party assemblies as Content with Copy to output directory set to Always copy.

In addition I''ve added an app.config to my solution.
The content, I guess it''s wrong :)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="svl:WPFSoundVisualizationLib">
      <probing privatePath="3rdParty;" />
      <dependentAssembly>
        <assemblyIdentity name="WPFSoundVisualizationLib" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>



当我尝试运行我的应用程序时,我得到一个System.Windows.Markup.XamlParseException说我的MainWindow类型的构造函数在x线的y位置抛出了异常. XAML的相应位置引用了我的第三方大会.



When I''m trying to run my application I get an System.Windows.Markup.XamlParseException saying that my constructor of type MainWindow threw an exception at line x position y.
At the according postion of my XAML is my 3rd party assembly referenced.

xmlns:svl="clr-namespace:WPFSoundVisualizationLib;assembly=WPFSoundVisualizationLib"



有人可以告诉我,我在做什么错吗?
预先谢谢.



Can anybody please tell me, what I''m doing wrong?
Thanks in advance.

推荐答案

好,我自己解决了.
但是我仍然不明白为什么项目项目属性中Reference Paths选项卡中的值不够或被忽略.

首先,正如所猜测的,app.config的内容是错误的.有关正确的格式,请参见下面的代码段.

此外,配置文件的名称必须与应用程序名称以及扩展名.config匹配.表示名称app.config必须替换为assemblyName.exe.config,并且必须将其复制到输出位置.

OK, I solved it myself.
But I still don''t understand why the value''s from the Reference Paths tab in the project project properties aren''t enough or getting ignored.

First of all, as guessed, the content of the app.config was wrong. See the snippet below for the correct format.

In addition, the name of the config file must match the application name plus the extension .config. Means the name app.config must be replaced with assemblyName.exe.config and it must be copied to the output location.

<configuration>
  <runtime>
    <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatepath="Common;3rdParty" />
    </assemblybinding>
  </runtime>
</configuration>


作为第三方,他们可能已经将自己加入了GAC.可能是您要引用的这些文件,而不是第三方文件夹中的二进制文件.检查引用的属性,以确保它们指向正确的路径.

顺便说一句,您不需要做配置工作;-)
Being third-party ones, they''ve probably put themselves in the GAC. It''s probably these ones you are referencing and not the binaries in your third-party folder. Check the properties of the reference to make sure they are pointing at the right path.

BTW, you don''t need to do the config stuff ;-)


这篇关于引用的程序集与项目输出的路径不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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