-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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.Location
is strictly better thanAssembly.CodeBase
.
Assembly.CodeBase
is an obsolete property. The only reason why it was included in .NET Core was .NET Framework compatibility. The original purpose ofAssembly.CodeBase
was 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.Load
method.
Proposed API
namespace System.Reflection
{
public partial class Assembly
{
[Obsolete("Use Location instead.")]
public virtual string CodeBase { get; }
}
}