MEF With Portable Class library using Microsoft Composition MEF2 throws file not found exception

223 Views Asked by At

I am working on Portable Class Library(PCL) and trying to achieve MEF in that. I used System.Composition from Nuget. When i build and package for vsix (Extension for Visual Studio) it doesn't package and place those dll's to extension folder (C:\Users\UserName\AppData\Local\Microsoft\VisualStudio\14.0Exp\Extensions\ExtensionName\AppName\versionofYourApp). When i manually place those library in this folder it works fine. Can some one suggest a good solution to this problem. I am writing it for Roslyn Analyzers and creating a nuget package. Again i am facing the same issue, even if i am packaging those library together.

2

There are 2 best solutions below

1
SLaks On

Set Copy Local to true in the VSIX's reference to the MEF DLLs.

0
shekhar Kumar On

I found a solution, thought of sharing. You are welcome to correct and suggest. For Vsix extension i added those library as an asset(VisualStudio.Assembly) from local.

And for packages, Assembly.Load("AssemblyName") was trying to load library from all possible locations like " C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies" and many. So i placed it there and it was getting loaded. I know this is not the best solution. You are most welcome to suggest.