.NET:Assembly.CodeBase vs. Assembly.Location

本文解释了在.NET框架中,CodeBase与Location属性的区别。CodeBase通常指向文件的原始位置,例如从互联网下载的文件其CodeBase可能包含HTTP链接;而Location属性则表示实际加载路径,如果是硬盘上的文件,则Location会指向具体的磁盘路径。如果文件被影子复制,Location会指向影子副本的位置。值得注意的是,对于全局程序集缓存(GAC)中的程序集,CodeBase可能未设置,但Location总是有值。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The CodeBase is a URL to the place where the file was found, while the Location is the path from where it was actually loaded. For example, if the assembly was downloaded from the internet, its CodeBase may start with "http://", but its Location may start with "C:\". If the file was shadow copied, the Location would be the path to the copy of the file in the shadow-copy dir.

It’s also good to know that the CodeBase is not guaranteed to be set for assemblies in the GAC. Location will always be set for assemblies loaded from disk, however.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值