mef

Strongly typed Razor views in dynamically loaded assembly don't compile at runtime

浪尽此生 提交于 2020-01-03 17:07:53
问题 I have a MVC3 Area in an assembly that is dynamically loaded with MEF. If I use the Webforms view engine with strongly typed views, everything works fine. If I use the Razor view engine with a dynamic model, it works fine too. But if I use a strongly typed Razor view , the view compilation fail at runtime. The problem is that the dynamically loaded assembly is not in the list of referenced assemblies passed to the C# compiler. The generated C# code looks like this: namespace ASP { using

Strongly typed Razor views in dynamically loaded assembly don't compile at runtime

一世执手 提交于 2020-01-03 17:07:25
问题 I have a MVC3 Area in an assembly that is dynamically loaded with MEF. If I use the Webforms view engine with strongly typed views, everything works fine. If I use the Razor view engine with a dynamic model, it works fine too. But if I use a strongly typed Razor view , the view compilation fail at runtime. The problem is that the dynamically loaded assembly is not in the list of referenced assemblies passed to the C# compiler. The generated C# code looks like this: namespace ASP { using

Project-Embedded IoC Container

前提是你 提交于 2020-01-03 10:58:12
问题 I am looking for a really simple and lightweight IoC Container whose C# source can be included in my own project (thus not making an external reference). The reason for this is that I am writing an infrastructure and would like to provide a single .dll file, without any additional dependencies. I also do not want to ILMerge my assembly with the IoC assembly.. I thought about MEF, some other suggestions? 回答1: If you're using .NET 4.0 you have MEF included. For .NET 2 I once wrote something

Project-Embedded IoC Container

耗尽温柔 提交于 2020-01-03 10:58:05
问题 I am looking for a really simple and lightweight IoC Container whose C# source can be included in my own project (thus not making an external reference). The reason for this is that I am writing an infrastructure and would like to provide a single .dll file, without any additional dependencies. I also do not want to ILMerge my assembly with the IoC assembly.. I thought about MEF, some other suggestions? 回答1: If you're using .NET 4.0 you have MEF included. For .NET 2 I once wrote something

Dynamically loading an assembly based on whether current process is x32 or x64

泪湿孤枕 提交于 2020-01-03 03:49:05
问题 I have some code which dynamically loads an assembly depending on the result of the Environment.Is64BitProcess property which is then used as required. Is this something MEF could do automatically without me having to use the Environment & Assembly classes? Or Would I have to write some kind of extension to MEF to achieve this? Framework version: .Net 4.0 回答1: Place 32 bit assemblies in one folder, and 64 bit assemblies in another. Then load the proper folder using MEF based on Environment

Visual Studio 2010 Pro - SuppressMessage

雨燕双飞 提交于 2020-01-02 01:56:28
问题 Is the option to SupressMessage not available in VS 2010 Pro? When I right click on the warning in the warning list there is no option to suppress. I also tried it with errors and there was no option. I then tried to create my own GlobalSuppression.cs file but have no idea what category the warning should be classified under. Right now I'm doing this, which works, but I would prefer to use a GlobalSuppression file #pragma warning disable 0649,0169 [Import(AllowRecomposition = false)] private

Is it possible to inject an existing instance into a MEF plugin?

拥有回忆 提交于 2020-01-01 12:08:07
问题 We are creating an application which supports plugins using MEF. We are determining what type of plugins the user is able to create, and want to use dependency injection to provide this type of plugin with the data it needs. For example, we make a plugin that is able to display a list. To achieve this, it needs the existing instance of the IRepository for the type of data the list will display. The IRepository is created somewhere else in a datacontext class, so we are unable to let MEF

C# MEF usage with static classes

放肆的年华 提交于 2020-01-01 08:24:23
问题 I have a static class in my solution which is used to work with various assemblies. I want to link them through MEF, so I made a field in a class. [Import(typeof(A))] static private A _a1; Then I have a method to which I pass assembly name as an argument: public static A LoadPackage(string filePath) { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(filePath)); var _container = new CompositionContainer(catalog); ??? } So is there a way now to import type from

MEF and ShadowCopying DLLs so that I can overwrite them at runtime

扶醉桌前 提交于 2020-01-01 08:19:09
问题 I am trying to stop my application locking DLLs in my MEF plugin directory so that I can overwrite the assemblies at runtime (note I'm not actually trying to have MEF reload them on the fly, at the next app start is fine, i just dont want to have to stop the app to do the copy) I am trying to do this by creating a shadow copied app domain for my mef loaded assemblies as below: [Serializable] public class Composer:IComposer { private readonly string _pluginPath; public Composer

MEF and ShadowCopying DLLs so that I can overwrite them at runtime

Deadly 提交于 2020-01-01 08:19:07
问题 I am trying to stop my application locking DLLs in my MEF plugin directory so that I can overwrite the assemblies at runtime (note I'm not actually trying to have MEF reload them on the fly, at the next app start is fine, i just dont want to have to stop the app to do the copy) I am trying to do this by creating a shadow copied app domain for my mef loaded assemblies as below: [Serializable] public class Composer:IComposer { private readonly string _pluginPath; public Composer