Quantcast
Channel: Managed Extensibility Framework
Viewing all 265 articles
Browse latest View live

New Post: Prism-MEF: Integerate LinqPad to my application as a Plug-in

$
0
0
Hi,
i've asked this question before in patterns & practices: Prism but there was no answer so i re-ask same question again.
I'm using MEF with Prism 4 in developing LOB application and i wonder if it is possible to integerate LinqPad 4 to my application to be launched from menu item or icon within my application and use it as any dialog box . Do MEF has this capability?
Thanks

New Post: Issue with .net 4.5 MEF

$
0
0
Hi,
I am new .net 4.5 MEF, and I am aware of using MEF in .net 4.0. I tried creating an application using MEF in .net 4.5 but when MEF try to create instance of the class it throws the below exception. "The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information." They provided some suggestions about constructor I tried all the possibilities but still I am getting the same error, but when I tried running the same code in VS 2010 it worked without issues. I am using Contracts for MEF with some metadata involved for filtering. Could somebody please help in figuring out the issue.

Thanks,
Bhaskar.

New Post: Using an XML Manifest

$
0
0
I am trying to figure out how to use an XML Manifest (e.g. contains 'paths' that can define the layout of menu items), kind of like the system in ICSharpCode.Core. I am not using ICSharpCode.Core due to the difficulty getting it to work with DevExpress controls.

Any ideas/suggestions/examples/etc? I may go to Mono.Addins, but I think making that work will be a real adventure.

New Post: ComposeParts Exception due Multitple Metadata entries

$
0
0
Dear All

My application uses DirectoryCatalog to import parts from third party dlls. The problem I have have is, ComposeParts fails to load every other when a single plugin developer decorates their exports with multiple metadata entries but fails to set IsMultiple attribute to true. This is something I have no control over.

My question is: is there a way I can configure my code so that that invalid metadata attributes like will not cause failure to load all other plugins in the folder?
OR can I instruct CompositionContainer to ignore exports with this problem?

Thanks in advance

Sam
[ImportMany]
private IEnumerable<Lazy<object, TDic>> item;

[Export(typeof(System.Func<string, object[], object>))]
[ExportMetadata("Name", "Name 1")]
[ExportMetadata("Name", "Name 2")]
public object Subtract(string f, object[] args) {
   return "Evaluate Subtract";
}

[Export(typeof(System.Func<string, object[], object>))]
[ExportMetadata("Name", "Name 1")]
[ExportMetadata("Address", "Address 1")]
public object Add(string f, object[] args) {
   return "Evaluate Add";
}
Both Subtract and Add resides in user's class. I want to be able to import 'Add' and ignore 'Subtract' because of the error due to multiple metadata entry without 'IsMultiple' flag being set. Any ideas on what I am doing wrong will be most welcome.

Thanks

New Post: Preserve Multiple Metadata Order

$
0
0
I have the following exported function:
[Export(typeof(System.Func<object>))]
[ExportMetadata("Name", "Name 1", IsMultiple = true)]
[ExportMetadata("Name", "Name 2", IsMultiple = true)]
[ExportMetadata("Name", "Name 3", IsMultiple = true)]
public object TestFunction() {return null;}
Problem is, when the function is imported, the order of the metadata IDictionary<string,object[]> is not preserved according to the order they are declared, which is important in my application.

Can anyone help with a solution or workaround?

Kind regards

Bright

New Post: Plugins with Common Dependencies?

$
0
0
Hi All,

So, I have been using MEF for a little while, I've written several plugins for an app already which work very well - they all use MVVM and the resources are all injected ok so far.

But... I have come across a problem, I have 3 plugins, P1, P2 and P3. Each one is using the Infragistics libraries to display data.

Unfortunately I am also using Click Once, so I have a Plugins Dir with the Dll's from my plugins linked, so that Click Once will deploy the Dll's. OK So far.

So, when I install on a machine that does not have the Infragistics Libraries installed it does not work. I cannot deploy the dependencies with each plugin (VS will not let me add multiple links to the same file, and also, there are going to be at least 10 plugins at the end, if each is using the same 10mb dependencies...)

So, I tried using the probing privatePaths to try and get a common dir that I can put common dependencies into, but I'm not having much luck.

Has anyone come across this problem before? if so, how should I overcome this problem?

Thanks for all advice!

Scott

New Post: Generic out of work when Use RegistrationBuilder

$
0
0
I would like to just use RegistrationBuilder to create parts.
example:
public interface IModel
{
    String Name { get; }
}

public interface IRepository
{
}

class ModelOne : IModel
{
    public String Name { get { return "ModelOne"; } }
}

class ModelTwo : IModel
{
    public String Name { get { return "ModelTwo"; } }
}

public interface IRepository<TModel> : IRepository where TModel : IModel
{
    IContext<TModel> Context { get; set; }
}

public class Repository<TModel> : IRepository<TModel> where TModel : IModel
{
}

    static void Main(String[] args)
    {
        var builder = new RegistrationBuilder();
        builder.ForTypesDerivedFrom<IModel>()
            .Export()
            .Export<IModel>();
        builder.ForTypesDerivedFrom<IRepository>()
            .ExportInterfaces();
        var asmCatalog = new AssemblyCatalog(Assembly.GetExecutingAssembly(), builder);
        var container = new CompositionContainer(asmCatalog);
        var one = container.GetExportedValue<IRepository<ModelOne>>();
        var two = container.GetExportedValue<IRepository<ModelTwo>>();
    }
I can not get the results(the one,the two) I want。

because when i use RegistrationBuilder the all type when wrapped in ProjectingType,but GetExportedValue method did not wrap Generic Parameters in ProjectingType.

My temporary solution is to modify the ImportDefinition.Metadata to make sure the Generic Parameters wrapped in ProjectingType.

is there any good solution or correction?

New Post: Temporary directory

$
0
0
I've just deployed an WCF service application that uses MEF to a QA environment and an issue jumped up and bit us. The security context under which the application is running must have read/write access to C:\windows\temp or strange things happen. The application loads, but when I try to access a custom section in my web.config, ConfigurationManager.GetSection returns a null. Through trace output, I get messages that looked like this:

Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\pmgl4mnt.0.cs' could not be found
error CS2008: No inputs specified

When I grant access to the proper user, everything works great.

Is it possible to configure MEF to use a different directory?

Thanks,
Todd

New Post: MEF2 with MVC4 via Microsoft.Composition

New Post: PRISM: Load by MEF new version of the same DLL.

$
0
0
Hello,

I am using PRISM with MEF. I have a problem which I think I am not able to solve with MEF, but I am not sure.

What I would like to achieve is to load by MEF the new updated version of given module. I am loading a module "A" in runtime by adding new DirectoryCatalog to the AggregateCatalog.Catalogs collection in my class which inherits from MefBootstrapper. And now I would like to load the new version of module "A", i.e. the DLL name is the same, module class name is the same, just different code inside.

When I am adding new DirectoryCatalog which holds the new version of DLL with module "A" then I get exception:
Activation error occured while trying to get instance of type RegionAdapterMappings, key ""
Is this what I would like to achieve possible with MEF and PRISM? Thank you for help.

New Post: ImportConstructor in class that is being serialized/deserialized

$
0
0
I incorporated MEF into a desktop application in which I serialize and deserialize the object. I use the ISerializable interface to control my binary serialization. During regular object instantiation the objects constructor is called in which it has an ImportingConstructor. How do you get MEF imports when the object is being created during deserializations using
MyObject(SerializationInfo info, StreamingContext context)?

New Post: ImportConstructor in class that is being serialized/deserialized

$
0
0
You could switch to property imports and fix them up post-deserialization, but I'd be concerned about the fragility of mixing parts and serialization this way. As a rule of thumb, things with a 'persistent identity' make poor parts- MEF really wants to be in control of which instance is used where.

In this situation I usually try to separate the serialized and non-serialized data into different (related) classes. This might work for you..?

Good luck!
Nick

New Post: ImportConstructor in class that is being serialized/deserialized

New Post: NullReferenceException

$
0
0
Hi all,
Seems that this post is the only one with the same problem as I have.
What was the cause of this issue?

New Post: A way to delete/replace a Shared object from the container

$
0
0
In my PRISM application I use MEF as a container. Most of my ViewModel are Non-Shared instances, but a couple are Shared due the requeriments (being used among different views).

But in certain moments I need to delete/release those ViewModel instances.

I know that I could make them Non-Shared and use statics methods to share data among the instances, but thats not a clean way to do it.

Is there a way to do it?

New Post: .NET 4.5 Constructor Parameters

$
0
0
How do I set constructor parameters in MEF2?

I assume there is a better way than changing the implementation with ImportingConstructor + Import ParamName.

If not, what happens if I don't have access to rebuilding the class implementation?

New Post: MEF2 with MVC4 via Microsoft.Composition

$
0
0
Nick provided the base for what is now WebApiContrib.IoC.Mef for use with Web API, as well. So if you want Web API support, take a look at that package.

New Post: Object lifetime of NonShared IDisposable parts

New Post: MEF RegistrationBuilder in .NET 4.0

$
0
0
I could really use and the new RegistrationBuilder from MEF2 in some .NET 4.0 applications. Is the code in the repository stable enough for me to build and use in my projects? Has anyone else tried this? If so, any issues or performance concerns that should be noted?

New Post: Defining Scope in MEF with CompositionScopeDefinition

Viewing all 265 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>