How to resolve generic type in Unity

2

I'm trying to resolve generic type trough Unity, but I'm getting error: {"The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)":null}.

My code and configuration is as follow:

namespace Prj.Common.Workflow
{
    public class ServiceActivityBase<I, O> : CodeActivity, IServiceActivityBase   
    {
    }
}

namespace Prj.Services
{
    public sealed class TestActivity : ServiceActivityBase<InputDto, OutputDto>
    {
    }
}

namespace Prj.Dto
{
    public class InputDto {}
    public class OutputDto {}
}

Each namespaces is placed in the separate asssembly with the same name as the namespace. I have a following registration in web.config:

<register   type="Prj.Common.Workflow.ServiceActivityBase'2[[Prj.Dto.DajDetailDietetickejPotravinyVstupDto,Prj.Dto],[Prj.Dto.DajDetailDietetickejPotravinyVystupDto,Prj.Dto]], Prj.Common.Workflow"
mapTo="Prj.Services.TestActivity, Prj.Services"
name="TestActivity"
>
<constructor/>
<interceptor type="VirtualMethodInterceptor"/>
<policyInjection />
</register>      

I'm receiving error while loading configuration:

IUnityContainer container = new UnityContainer().LoadConfiguration();    

Can somebody help?

thanks

c#
unity-container
asked on Stack Overflow Jan 26, 2012 by zosim

1 Answer

0

Have you tried registering the dependency in code? This might help you narrow down issue. Registration should look like this: container.RegisterType<ServiceActivityBase<InputDto,OutputDto>,TestActivity>(). This way you would know if your issue is only in your XML file.

answered on Stack Overflow Feb 28, 2014 by mmilleruva

User contributions licensed under CC BY-SA 3.0