获取参考项目的装配 [英] Get assembly of reference projects

查看:77
本文介绍了获取参考项目的装配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我的项目中有一些奇怪的问题。



我创造了两个名为website.Web和website.Admin作为区域,网站的MVC项目.Admin项目位置在website.web下,与NopCommerce结构相同。 website.Admin项目是在website.Web bin文件夹下构建的。



我在global.cs文件中编写代码,通过以下代码查找bin文件夹中添加的程序集。



Hello friends,

I have some strange problem in my project.

I have created tow MVC projects named website.Web and website.Admin as area, website.Admin project location is under of website.web same as NopCommerce structure. website.Admin project is built under website.Web bin folder.

I have written code in global.cs file to find out assembly added in bin folder by following code.

AppDomain.CurrentDomain.GetAssemblies()

不返回website.Admin程序集已经放入在bin文件夹下。当我清除整个解决方案并再次构建然后我得到管理项目的程序集,但是当我添加一些图像文件或视图,并构建以运行项目,然后找不到程序集。我必须创建解决方案来解决上面的代码。



我已经改变了项目的构建顺序但是没有用。



有谁能指导我这里有什么实际问题吗?



谢谢

Imrankhan

that does not return website.Admin assembly which is already put under bin folder. When I clear the whole solution and build again then I get the assembly of admin project but when I add some image file or view, and build to run the project then assembly not found. I have to crear the solution to work out the above code.

I have changed the build order of projects but that didn''t work.

Can anyone guide me what are the actual problem here?

Thanks
Imrankhan

推荐答案

你应该明白这个调用优化了引用但未真正使用的程序集。



(引号是有意的。当然,加载过程实际上会优化它,而Application Domain会报告实际加载的内容。相比之下, System.Assembly.GetReferencesAssemblies 列出所有什么是正式引用,但其中一些程序集可能没有物理加载。通常,这是构建中使用的冗余引用的结果,这是一种常见的开发缺点。)



我不知道你在你的网站或网页上引用和实际使用的是什么,但我我很确定如果你分析我刚才解释的事实,你会很快找到目的。



-SA
You should understand that this call "optimizes out" the assemblies which are referenced but not really used.

(Quotation marks are intended. Of course, the process of loading actually optimizes it, and Application Domain reports what is actually loaded. In contrast, System.Assembly.GetReferencesAssemblies lists all what is formally referenced, but some of these assemblies may be not physically loaded. Usually, this is the result of redundant references used in the build, a kind of a usual development drawback.)

I don''t know what you are referencing and actually using on your site or a page, but I''m pretty sure that if you analyze the facts I just explained, you will quickly find the ends.

—SA


感谢您的宝贵回复。



我通过BuildManager.GetReferencedAssemblies()而不是AppDomain.CurrentDomain.GetAssemblies()修复了它。 />


我不知道是否正确,但问题现在已经解决了。会考虑一下。



谢谢

Imrankhan
Thanks for your valuable reply.

I have fixed it by BuildManager.GetReferencedAssemblies() instead of AppDomain.CurrentDomain.GetAssemblies().

I don''t know whether it is right way or not, but problem is fixed for now. Will be think about it.

Thanks
Imrankhan


这篇关于获取参考项目的装配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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