c# - How are PCL references resolved? -
i'm looking options port wpf-oriented library pcl library can used on multiple platforms, windows store applications.
from understand, portable class library references subset of .net libraries supported on platforms target, , limited following assemblies:
- mscorlib.dll
- system.dll
- system.core.dll
- system.xml.dll
- system.componentmodel.composition.dll
- system.net.dll
- system.runtime.serialization.dll
- system.servicemodel.dll
- system.xml.serialization.dll
- system.windows.dll (from silverlight)
and microsoft adds following that:
however, not of these assemblies supported on platforms. in portable class library project, specify platforms want target, , supported assemblies platforms referenced in project. if try reference assembly not supported platforms have targeted, visual studio warns of incompatibility. core assemblies (mscorlib.dll, system.dll, system.core.dll, , system.xml.dll) supported on platforms.
now, when making pcl library, reference .net portable subset
, , can't add reference it; vs tell me possible references have been added already.
now question quite simple: when actual references determined, , who determines these? done compiler @ compile time, or clr @ runtime?
when actual references determined,
at runtime of course, time when can discovered code runs on, say, silverlight.
and determines these?
the clr. maps retargetable assembly reference inside compiled assembly concrete assembly that's available on machine. retargeting generic capability of later clr versions, that's example how can use .net 2.0 assembly in .net 4.0 program. though has reference mscorlib version 2.0.0.0 runs 4.0.0.0
much same in pcl library, target version 2.0.5.0 of mscorlib.dll, version not exist. fake assembly reference produced reference assemblies compile program with. stored in c:\program files (x86)\reference assemblies. compiler doesn't know better version real. there many sets of reference assemblies, called profiles, engineered expose types can hope use on target machine. when start pcl project pick targets , automatically picks correct profile, 1 collection out of set of reference assemblies that's guaranteed work on of targets picked. more targets select, less types can use in library code.
this retargeting can of course done "known" assemblies, ones clr has pre-built knowledge on how map. why cannot add arbitrary framework assembly reference, there no hope clr maps correct 1 @ runtime. , of all, little hope available on machine.
Comments
Post a Comment