mef

一起了解 .Net Foundation 项目 No.10

懵懂的女人 提交于 2020-03-03 08:22:36
.Net 基金会中包含有很多优秀的项目,今天就和笔者一起了解一下其中的一些优秀作品吧。 中文介绍 中文介绍内容翻译自英文介绍,主要采用意译、如与原文存在出入,请以原文为准。 LLILC LLILC (读作 ‘lilac’) 是一个基于 LL VM 的 MS IL 编译器。该项目的目标是创建一组利用LLVM的.Net工具,这些工具可以延伸运行于多种平台和芯片架构。 今天,LLILC 被作为 JIT 的形式用于开发 dotnet/CoreCLR ,不过新的 AOT 编译器也将在未来面世。 项目详情 官方网站 项目源码 项目许可证: MIT 项目联系人: Russell Hadley 相关链接 项目文库 参与贡献 参与讨论 笔者简评 笔者对于编译原理及其底层了解不深,因此此处只能汇采一些互联网中的内容。 回顾LLILC的六个月 LLVM LLVMSharp 英文介绍 LLILC LLILC (pronounced ‘lilac’) is an LL VM based MS IL C ompiler. The goal of the project is to produce a set of .NET tools that utilize LLVM to reach a broad set of platforms and chip architectures. Today LLILC

Exception during initialization of a CodeRefactoringProvider when trying to import DTE

ⅰ亾dé卋堺 提交于 2020-01-25 10:10:47
问题 I am building a custom code refactoring provider as an extension to Visual Studio 2017 and I want it to access the DTE service. To get it I use the ImportingConstructorAttribute and declare the service a parameter: [ExportCodeRefactoringProvider( LanguageNames.CSharp, Name = nameof( MyCodeRefactoringProvider ) )] [Shared] internal class MyCodeRefactoringProvider : CodeRefactoringProvider { private readonly DTE m_dte; [ImportingConstructor] public MyCodeRefactoringProvider( DTE dte ) { m_dte =

Exception during initialization of a CodeRefactoringProvider when trying to import DTE

自古美人都是妖i 提交于 2020-01-25 10:10:09
问题 I am building a custom code refactoring provider as an extension to Visual Studio 2017 and I want it to access the DTE service. To get it I use the ImportingConstructorAttribute and declare the service a parameter: [ExportCodeRefactoringProvider( LanguageNames.CSharp, Name = nameof( MyCodeRefactoringProvider ) )] [Shared] internal class MyCodeRefactoringProvider : CodeRefactoringProvider { private readonly DTE m_dte; [ImportingConstructor] public MyCodeRefactoringProvider( DTE dte ) { m_dte =

C# WCF plugin design and implementation

南楼画角 提交于 2020-01-22 19:48:14
问题 I would like to get some advice. I am developing a system that will load up plugins at runtime and require them to be available through a WCF endpoint. I will have a MVC 3 Web app that is only really used for configuration, and a class library (core) that will load up different plugins. I would appreciate some guidance on how to go about this. I would like to load the plugin up and then be able to create a WCF endpoint that is registered with IIS 7 for access into that plugin. Thanks in

C# WCF plugin design and implementation

蹲街弑〆低调 提交于 2020-01-22 19:47:08
问题 I would like to get some advice. I am developing a system that will load up plugins at runtime and require them to be available through a WCF endpoint. I will have a MVC 3 Web app that is only really used for configuration, and a class library (core) that will load up different plugins. I would appreciate some guidance on how to go about this. I would like to load the plugin up and then be able to create a WCF endpoint that is registered with IIS 7 for access into that plugin. Thanks in

CompositionContractMismatchException when trying to use MEF with MVC controller

≯℡__Kan透↙ 提交于 2020-01-19 12:44:48
问题 I'm working on a bigger C# MVC 4 project which is divided in several assemblies (Core, Domain, Backend MVC, Frontend MVC etc.). I use the plugin architecture provided by MEF to load and resolve most dependencies. Now I also wanted it to use to load MVC controller. Typical scenario found in dozens of samples. But I keep getting this YSOD: The exception says: [CompositionContractMismatchException: Cannot cast the underlying exported value of type "XY.HomeController (ContractName="XY

F# and MEF: Exporting Functions

不问归期 提交于 2020-01-15 04:15:32
问题 So, I was trying to get this simple test working in an F# console app: open System.Reflection open System.ComponentModel.Composition open System.ComponentModel.Composition.Hosting [<Export(typeof<int -> string>)>] let toString(i: int) = i.ToString() [<EntryPoint>] let main argv = use catalog = new AssemblyCatalog(Assembly.GetEntryAssembly()) use container = new CompositionContainer(catalog) let myFunction = container.GetExportedValue<int -> string>() let result = myFunction(5) 0 I expected

F# and MEF: Exporting Functions

做~自己de王妃 提交于 2020-01-15 04:15:27
问题 So, I was trying to get this simple test working in an F# console app: open System.Reflection open System.ComponentModel.Composition open System.ComponentModel.Composition.Hosting [<Export(typeof<int -> string>)>] let toString(i: int) = i.ToString() [<EntryPoint>] let main argv = use catalog = new AssemblyCatalog(Assembly.GetEntryAssembly()) use container = new CompositionContainer(catalog) let myFunction = container.GetExportedValue<int -> string>() let result = myFunction(5) 0 I expected

MEF error, was circular dependency and is now something else

故事扮演 提交于 2020-01-13 12:06:54
问题 I've got a circular dependency that recently came about because of a change in my application architecture. The application relies on a plugin manager that loads plugins via MEF. Everything up until worked fine, because it looked something like this: // model.cs [Export("Model")] public class Model { public PluginManager PM { get; set; } [ImportingConstructor] public Model( [Import] PluginManager plugin_manager) { PM = plugin_manager; } } // pluginmanager.cs [Export(typeof(PluginManager))]

MEF ComposeParts. How to handle plugin exceptions

独自空忆成欢 提交于 2020-01-13 11:26:46
问题 I have searched on the web for a solution, but I didn't find anything. In my C# application I am using MEF for implementing a plugin pattern. Everything is working fine. However today I have tried to figure out what happens if a Plugin Constructor throws an Exception for some reason. To load plugins I am using CompositionContainer.ComposeParts . If for some reason one of the X plugins throws an exception this method will fail and nothing will be loaded. Is there a way to just catch the single