Description
GetType() in base class constructor, when call from derived class, returns differently between runs as a dynamically loaded plugin when the host loading program is:
- normally compiled (that returns derived type) and ,
- published as a single package (that return basetype)?
targeting net8, but compiled with net9 compiler in my case.
Reproduction Steps
write an assembly with following class to be built as a plugin:
public class BaseClass
{
public string TypeName;
public BaseClass()
{
TypeName = GetType().FullName;
}
}
public class SubClass : BaseClass
{
public SubClass()
{
}
/// <summary>
/// This method behave and output differently from run compiled and published as single package.
/// </summary>
public void PrintMyTypeInfo()
{
Console.WriteLine(TypeName); //<- outputs "SubClass" as as the host program run as normal compiled, but outputs "BaseClass" when host program published as single package.
}
}
Load this plugin with above classes from the host program which is built as normlly or published as a single package, the output of PrintMyTypeInfo() are different.
Expected behavior
it should behave the same!
Actual behavior
output "SubClass" as run compiled but "BaseClass" as published single package, targeting net8.
Regression?
No response
Known Workarounds
Write Gettype() in constructors of all derived subclasses.
Configuration
targeting net8 but compiled by net9 compiler
Other information
No response