如何在wpf中创建两个项目之间的引用? [英] how to create a reference between two project in wpf?

查看:823
本文介绍了如何在wpf中创建两个项目之间的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在wpf中创建两个项目之间的引用?

how to create a reference between two project in wpf?

推荐答案

引用始终不是在项目之间创建的,而是在程序集之间创建的:

http://msdn.microsoft.com/en-us/library/ hk5f40ct%28v = vs.90%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/yx7xezcf%28v=vs.110%29.aspx [ ^ ]。



尽管如此,在Visual Studio中,您可以引用另一个项目。在解决方案资源管理器中,使用添加引用,然后在添加引用窗口中,单击项目选项卡。它给你带来了什么?



从本质上讲,这只不过是 Solution 级别的一些开发自动化,它可以让你避免直接引用程序集,但它们的可执行模块(通常是.DLL文件,但它可以是任何其他内容,甚至是.EXE)。您可以使用强名称程序集(强烈推荐),稍后更改程序集的程序集签名,版本或位置(输出路径,在项目级别)。所有这些更改都可能使对程序集的引用无效。项目的引用解决了它。无论你对要引用的项目做什么,对它的引用基本上都告诉MSBuild:引用项目在输出上产生的任何程序集。在此方法中,您可以大胆地对程序集应用任何更改,它们将通过项目文件保留的信息正确找到并引用。方便,对吧?



但就运行时而言,程序集引用其他程序集,而不是项目。从运行时的角度来看,项目不存在。



-SA
References are always created not between projects but between assemblies:
http://msdn.microsoft.com/en-us/library/hk5f40ct%28v=vs.90%29.aspx[^],
http://msdn.microsoft.com/en-us/library/yx7xezcf%28v=vs.110%29.aspx[^].

Nevertheless, under Visual Studio you can reference one project by another one. In Solution Explorer, use "Add Reference", and, in the "Add Reference" window, click the tab "Projects". What it gives your?

Essentially, this is nothing more than some automation of development at the level of a Solution which allows you to avoid direct referencing of assemblies, but their executable modules (usually, .DLL files, but it can be anything else, even .EXE). You can use strongly named assemblies (highly recommended), and later change the assembly signatures, version or location of the assembly (output path, at the project level). All this changes may make a reference to the assembly invalid. Referencing of the projects resolves it. No matter what you do with the project to be references, the reference to it essentially tells the MSBuild: "reference whatever assembly that project produces on output". In this approach, you can boldly apply any changes to assemblies, they will be correctly found and referenced through the information kept by the project files. Convenient, right?

But as far runtime is concerned, an assembly references other assemblies, not projects. From the perspective of runtime, "projects" do not exist.

—SA


这篇关于如何在wpf中创建两个项目之间的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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