Background: We have three assemblies:
-
printing (Generates reports as pdfs) -> Reference to businessObjects.interfaces
-
businessObjects (contains all of our business objects) -> Reference to businessObjects.interfaces
-
businessObjects.interfaces (Here we declare the properties for the printing, only properties that are needed are included) -> No references
The object is implemented like this:
public interface IDeliveryNote // Assembly: businessObjects.interfaces
public partial class DeliveryNote : IDeliveryNote // Assembly:businessObjects
There is also a class 'Order' inside the DeliveryNote, holding a bool 'IsNeutralDelivery'
Problem: Some report(DeliveryNoterReport) was buggy and we needed to include an existing property (IsNeutralDelivery) from the businessObjects.DeliveryNote.Order - object. Actually we cant rollout the application (Dont ask :))
While debugging I noticed that from
IDeliveryNote dn = ((IDeliveryNote)this.DataSource);
i can access also the Order and the needed property (IsNeutralDelivery) maybe just fancy visual studio magic, so i tried to get the property with reflection like this:
bool neutralDeliveryAddressIsNeutralDelivery = (bool)dn.GetType().GetProperty("Order").GetValue(dn).GetType().GetProperty("IsNeutralDelivery").GetValue(dn.GetType().GetProperty("Order").GetValue(dn));
And yes, I retrieved the value and with that I could fix the bug (Only replace the printing.dll)
Question: Why I can get a instance of the DeliveryNote object when i got no references to the assembly that it belongs to.
Aucun commentaire:
Enregistrer un commentaire