简体   繁体   English

不在GAC中时如何使用我的DLL

[英]How to use my DLL when it is not in the GAC

If I have a Project which uses my own made .dll and this .dll is not registered with the GAC but simply in the same folder as my projects App. 如果我有一个使用自己制作的.dll的项目,而该.dll没有在GAC中注册,而只是在与我的项目App相同的文件夹中。 eg C:\\Program Files (x86)\\MyApp Folder. 例如C:\\ Program Files(x86)\\ MyApp文件夹。

Can I, and more importantly how do I properly reference this .dll if I want to for example build a second project which also uses this .dll. 我可以,更重要的是,如果要构建另一个也使用此.dll的项目,该如何正确引用此.dll。 It is possible that I build a few small apps that will use this .dll. 我可能会构建一些将使用此.dll的小型应用程序。

In this case must I have it in the GAC or if it is not there what must I do? 在这种情况下,我必须将其保存在GAC中,否则,该怎么办?

If I have a Project... 如果我有一个项目...

You should never put yourself in a situation where you have just a project. 您永远不要把自己放在只有一个项目的情况下。 You first and foremost have a solution . 您首先要有解决方案 A collection of projects that, together, build an app. 一起构建应用程序的项目的集合。 Projects of course have a dependency on each other, you use a project dependency to tell the compiler about. 当然,项目之间是相互依赖的,您可以使用项目依赖关系来告诉编译器。 Which automatically takes care of reference assemblies, the output of one project becomes the reference of another. 它会自动处理参考程序集,一个项目的输出将成为另一个项目的参考。 And any changes you make to the source code of such a project automatically propagate to the others. 您对此类项目的源代码所做的任何更改都会自动传播到其他项目。

This is usually as far as teams take it. 通常就团队而言。

This however tends to not work so well on very large solutions with dozens of projects, Visual Studio tends to get sluggish and building can take a long time. 但是,这在包含数十个项目的大型解决方案中往往无法很好地发挥作用,Visual Studio往往会变得缓慢,并且构建可能会花费很长时间。 An important step to take in such a case is to freeze a root project. 在这种情况下采取的重要步骤是冻结根项目。 A programmer needs to get an explicit permission to make changes to such a core project. 程序员需要获得明确的许可才能对此类核心项目进行更改。 Because such a change tends to be very destabilizing, requiring many changes in dependent projects. 因为这样的更改往往会非常不稳定,所以需要在依赖项目中进行很多更改。 And effectively destroys many hours of testing and validation time. 并有效地破坏了许多小时的测试和验证时间。

You do this by explicitly removing a project from a solution. 通过从解决方案中明确删除项目来执行此操作。 Which now automatically makes it difficult to make changes to it. 现在,这将自动使其难以更改。 The dependent projects need to be updated to use an explicit reference assembly instead of the project dependency. 需要更新从属项目以使用显式参考程序集而不是项目从属项。 Picking a well-known location for the assembly is important. 选择装配的知名位置非常重要。 Either source control or (preferrably) a build server is instrumental to be the source of the assembly. 源控件或(最好是)构建服务器都可以作为程序集的源。 A tool like Nuget can be very useful. Nuget之类的工具可能非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM