-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Assembly.Location and Assembly.CodeBase are very similar, but not the same thing. To reduce confusion, we should mark it as obsolete.
Reason
Having two things that are similar, but not identical always causes confusion. Here is an example.
Assembly.Locationis strictly better thanAssembly.CodeBase.
Assembly.CodeBaseis an obsolete property. The only reason why it was included in .NET Core was .NET Framework compatibility. The original purpose ofAssembly.CodeBasewas CAS (Code Access Security). It was meant to describe where the assembly was downloaded from for the Internet Zone security checks. It also explains some of its weird behaviors. For example, if the assembly is loaded as byte array, it returns the location of the caller of theAssembly.Loadmethod.
Proposed API
namespace System.Reflection
{
public partial class Assembly
{
[Obsolete("Use Location instead.")]
public virtual string CodeBase { get; }
}
}