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

  • Apple starts shipping new iPod touch, iPod nano
    W hen Apple  revealed  the new fifth-generation iPod Touch and the seventh-generation iPod nano at the widely-covered event in San Francisco...
  • Apple Will Announce iPhone 5 On September 12th Event
    Apple is known to be extremely secretive about upcoming product launches. We all know that the company takes the wraps off one flagship ha...
  • IFA 2012: HTC Announces Desire X Android 4.0 Budget Mobile Phone With 4" Screen
    After garnering some not-so-great reviews on its flagship handset the  One X ,  HTC  seems to be pinning its hopes on its mid-range Android ...
  • Best free iPhone apps of all time
    What are the best free iPhone apps worth downloading right now? Although there are a lot of great free iPhone apps to choose from, time is m...
  • IFA 2012: 10 best gadgets on display
                                                                                                                                                ...
  • Download: nexGTv Watch free live TV on your smartphone.
    View the full image nexGTv is a video streaming app that offers live TV on the move. Unlike other apps though, this one actually works, and ...
  • Sony Rolls Out Android 4.0 Upgrade For Xperia go, U, sola, And Tablet S
    Sony  has just given its users something to smile about. Ever since the  Xperia U ,  sola ,  and  go  were released , owners had been stuck ...
  • Review: Hitman: Sniper Challenge (PS3)
      Pros: Super addictive; Sniping is satisfying; Unlockable abilities; Requires good strategy to achieve high scores. Cons: Occasionally dumb...
  • F1 2012 – FULL – UNLOCKED – MULTI8
    F 1 2012 is set to deliver the most accessible and immersive FORMULA ONE game for fans of all abilities. In F1 2012 players will feel the un...
  • Microsoft launches Windows Server 2012
    M icrosoft officially released Windows Server 2012 today. The new OS shares quite a few things with Windows 8 such as the kernel and the UI....

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