Deploy your equipment locally and globally

MEF: DLL Versions and Multiple Exports for a Class

During my talk about the Managed Extensibility Framework (MEF) at Devscovery this past week, I had two very good questions asked by the audience and promised I’d get an answer.

The first one was about exporting in MEF. I was under the impression that a MEF part could have one export, but I was mistaken. The confusion came from this thread which doesn’t question multiple exports, but rather the shared policy (whether there is one export, or multiple instances of an export created). It’s one of those cases where I had read that and somehow got it in my head it wasn’t supported, and then simply didn’t have a reason to need it so I never investigated it further.

So, thanks for the great question.

Answer One: you can export a single class under multiple interfaces. Not a problem. And, depending on your creation policy, you can ensure only one instance is exported, or a separate interface for the different contracts.

The second one was a little more interesting. It was about versioning and DLLs. The question was if I import an assembly that has a part, then update the assembly on disk, can I pull in the new version?

Answer Two: no, you cannot reload a newer version of the assembly when it is updated on disk This isn’t a MEF limitation, but part of the CLR itself. If you think about it, you cannot do this without MEF, either. You might overwrite the DLL, but it will not get loaded (if it already is loaded) until you restart the application. Technically, you can unload the entire app domain or launch a new app domain, but you cannot unload the assembly within an app domain.

Wintellect’s Jeffrey Richter explains it well in this dot net rocks interview (PDF transcript). He says:

No you cannot and we will probably never offer that feature. If you think about it, if you load an assembly into an app domain and then you start executing code in that assembly, that may cause other assemblies to get loaded into that app domain as well. And then if you unloaded the first one, we don’t know to unload all the others that got loaded accidentally, if you will. So that is one of the reasons why we have app domains, is so that you can do this unloading and then all the other assemblies that got loaded as a side effect get unloaded at the same time. And we are probably going to keep that. We have heard that request from many people that if they want to unload an assembly, may be some day we’ll add it, but I think it’s very unlikely.

Thanks to everyone who attended and hope this answers your questions.

Jeremy Likness

Improve
system uptime.

Decrease
resolution times.

Rely on proven
data centers.

Plan a path
to the cloud.

Together we will reduce the potential for business impacting outages by leveraging modern and secure data centers.

Confidently take advantage of a highly trained 24x7x365 team of professionals who can perform remote hands services.

We deliver environments that are SSAE Type II audited by a third party and N+1.

We can help you migrate to a public, private or combination cloud using our deep knowledge and real world experience.

Visit our award winning data centers.

Schedule a Tour

Enterprise-Grade Colocation

Atmosera owns and operates secure data centers for customers that need full-service space, power and cooling. We offer secure racks, cabinets and cages, and network connectivity from multiple network providers.

3

1

21,000+

Locations in Portland, OR

Location in Phoenix, AZ

Square Feet in Portland, OR

Atmosera owns three flagship data centers in the Portland, Oregon metropolitan area and operates a Disaster Recovery (DR) site in Phoenix, Arizona.

  • Data Center

    Address

  • Beaverton, OR

    9610 SW Sunshine Ct

  • Beaverton, OR

    9705 SW Sunshine Ct

  • Data Center

    Address

  • Phoenix, AZ

    615 N 48th St

  • Portland, OR

    511 SW 10th Ave

Reliable, Secure, Audited

All Atmosera operated data centers are SSAE 16 Type II, audited by a third party and offer 24x7x365 secure access with two-factor authentication, and individually keyed cabinets and cages. Atmosera’s Technical Assistance Command Center (TACC) provides around the clock monitoring and remote hands service for customers who need it.

Cloud Migration Path

From colocation to cloud is easier than you might think. Many Atmosera customers have enlisted our help to migrate into the cloud from their existing colocation deployments. Some customers are also maintaining their colocation while deploying new applications in a private or public cloud and running a true hybrid deployment. Regardless of where you are in your cloud journey, Atmosera can help you with your colocation and any cloud migrations to meet your business needs.


Managed Colocation Services

To meet every customer’s requirements, we offer the following:

  • Racks, full cabinets or secure cages
  • Network connectivity from multiple service providers
  • Fully managed network infrastructure
  • Multiple hardened layers of security, reliability and protection
  • Rigorous operations and maintenance procedures
  • 24x7x365 secure access with two-factor authentication, and individually keyed cabinets and cages

24x7x365 Support

Professional services and fully managed deployment options include:

  • Faster remediation via remote hands and ongoing assistance
  • Architecture, design, procurement and installation services
  • 24x7x365 monitoring of services and equipment
  • Managed security
  • Data protection and backup

Other services you may find interesting:

Explore Our Resources

Download Data Sheets, Case Studies and Infographics.
View our Videos featuring demos and customer insights.

View Resources

We deliver solutions that accelerate the value of Azure.

Ready to experience the full power of Microsoft Azure?

Start Today

Blog Home

Stay Connected

Upcoming Events

All Events