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

2

0

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.

Configurationism answered 13/4, 2016 at 10:40 Comment(2)
Visual Studio ships with a copy of System.Composition, which is why we don't package them with you. What are you really trying to do? Did you start with our analyzer template?Ranket
yes, i used the VS Template for roslyn analyzer. I am trying to achieve Mef in the Analyzer for my custom functions like reading rules remotely placed at common place. Since the Analyzer is pcl so i had to create Core and implementation library which is PCL.By using MEF i am loading implementation library from core library.Configurationism
J
0

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

Jarredjarrell answered 13/4, 2016 at 13:40 Comment(1)
It's set Copy Local True. Same result.Configurationism
C
0

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.

Configurationism answered 13/4, 2016 at 16:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.