Games For Windows Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, 23 July 2013

Specifying an Assembly's Location with MEF

Posted on 08:00 by Unknown
Today I came across a problem with dynamically loading assemblies using MEF, when the assembly being loaded has a dependency on yet another assembly. In my case this was SignalR.

Assembly Host (.exe) -> Assembly (.dll) -> SignalR (.dll)

I was typically seeing the error:
Could not load file or assembly 'AssemblyNameHere, PublicKeyToken=xxxxxxxxxxxxxxxxx' or one of its dependencies. The system cannot find the file specified.

The reason for this is because the CLR is looking for the dependency in the directory in which the assembly host is running, and not the location of the assembly MEF loaded in.

The way around this is in this MSDN article. By using the probing tag in the app.config, you can specify the directory to look for dependencies. The caveat with using probing is you can only specify sub-directories of the assembly host, so if you want to use an absolute path to another place on the disk then probing isn't the solution, but I'd argue whether you needed it in another place anyway.

The config change required should look something like this:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="Modules\"/>
    </assemblyBinding>
  </runtime>
</configuration>
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Categories

  • .net
  • a
  • aakash
  • acer
  • agility
  • anchor free hotspot sheild app
  • andoid
  • android
  • android buyers
  • android update on samsung galaxy tab
  • apple
  • apps
  • asus
  • blackberry
  • blog
  • buy best android
  • c#
  • cpp
  • dell
  • developer
  • facebook
  • galaxy s3 explodes
  • gaming
  • get android
  • google
  • google android 4.1
  • google news
  • googletab
  • hathway
  • hcl
  • hp
  • htc
  • html
  • htmlagilitypack
  • huawei
  • iball
  • indian isp block
  • intex
  • ios apps
  • ios london 2012
  • iphone
  • iphone 5
  • jokes
  • junior
  • karbonn
  • lenovo
  • lg
  • linq
  • london 2012 mobile game
  • maps
  • mercury
  • micromax
  • microsoft
  • microsoft news
  • microsoft smartphone
  • motorola
  • new android 4.1
  • new apple iphone 5
  • new microsoft phone
  • new windows phone
  • news
  • nokia
  • nokia 808 pureview
  • nokia vs samsung
  • pack
  • programming
  • samsung
  • samsung galaxy s3
  • samsung galaxy s3 vs nokia 808
  • samsung galaxy tab
  • shopping
  • sony
  • sony xperia s ics update
  • sonygame
  • spice
  • swiftkey 3
  • swiftkey keyboard for android
  • tablets
  • torrent blocked sites
  • Tricks And Other Info
  • tumblr for ios
  • unblock torrent sites
  • upcoming android
  • videocon
  • windows
  • windows 7.8 update
  • windows phone 8
  • wishtel
  • wp 7.8
  • xbox
  • xperia s update
  • yahoo

Blog Archive

  • ▼  2013 (45)
    • ►  August (2)
    • ▼  July (2)
      • Specifying an Assembly's Location with MEF
      • Dragging a ListView control in a fullscreen WPF to...
    • ►  June (1)
    • ►  May (7)
    • ►  April (1)
    • ►  March (15)
    • ►  February (14)
    • ►  January (3)
  • ►  2012 (462)
    • ►  November (2)
    • ►  October (124)
    • ►  September (93)
    • ►  August (60)
    • ►  July (106)
    • ►  June (77)
Powered by Blogger.

About Me

Unknown
View my complete profile