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

浪子不回头ぞ 提交于 2019-12-12 02:53:16

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/36595897/mef-with-portable-class-library-using-microsoft-composition-mef2-throws-file-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!