orleans icon indicating copy to clipboard operation
orleans copied to clipboard

LightInject integration issue

Open n-sidorov opened this issue 8 years ago • 4 comments

I am trying to use LightInject as IoC container in Orleans Silo and on startup it throws an error Common Language Runtime detected an invalid program.

This looks like some issues with assembly loading and the root cause of it is that LightInject can't resolve IOptionsFormatter<> (which may be separate issue).

Tested with::

  • Microsoft.Orleans.Server 2.0.3
  • LightInject 5.1.5
  • LightInject.Microsoft.DependencyInjection 2.0.7

Integration code looks like this:

var container = new LightInject.ServiceContainer(opts);
var siloBuilder = new SiloHostBuilder()
    .UseServiceProviderFactory(services =>
    {
        return container.CreateServiceProvider(services);
    })

Full stack:

at DynamicMethod(Object[] )
at LightInject.Microsoft.DependencyInjection.PerRootScopeLifetime.CreateScopedInstance(Func`1 createInstance)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at DynamicMethod(Object[] )
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Orleans.Runtime.SiloOptionsLogger.OnStart(CancellationToken token) in D:\build\agent\_work\18\s\src\Orleans.Runtime\OptionsLogger\OptionsLogger.cs:line 22
at Orleans.LifecycleExtensions.Observer.OnStart(CancellationToken ct)
at Orleans.Runtime.SiloLifecycleSubject.MonitoredObserver.OnStart(CancellationToken ct) in D:\build\agent\_work\18\s\src\Orleans.Runtime\Lifecycle\SiloLifecycleSubject.cs:line 70
at Orleans.LifecycleSubject.WrapExecution(CancellationToken ct, Func`2 action) in D:\build\agent\_work\18\s\src\Orleans.Core\Lifecycle\LifecycleSubject.cs:line 103
at Orleans.LifecycleSubject.OnStart(CancellationToken ct) in D:\build\agent\_work\18\s\src\Orleans.Core\Lifecycle\LifecycleSubject.cs:line 49

Dotnet info:

> dotnet --info                                     
.NET Core SDK (reflecting any global.json):         
 Version:   2.1.300                                 
 Commit:    adab45bf0c                              
                                                    
Runtime Environment:                                
 OS Name:     Windows                               
 OS Version:  10.0.15063                            
 OS Platform: Windows                               
 RID:         win10-x64                             
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\  
                                                    
Host (useful for support):                          
  Version: 2.1.0                                    
  Commit:  caa7b7e2ba                               

Full solution that can reproduce the issue can be found here: https://github.com/n-sidorov/OreansLightInjectIssueRepro

n-sidorov avatar Aug 01 '18 13:08 n-sidorov

I've also opened similar issue on LightInject repo https://github.com/seesharper/LightInject/issues/432

n-sidorov avatar Aug 01 '18 13:08 n-sidorov

Looks like a LighInject issue, instead of Orleans issue. Since it is LighInject cannot resolve certain type, instead of incompatibility with Orleans. Does the suggestion from LightInject solve your problem?

And so sorry for the late reply.

xiazen avatar Mar 18 '19 22:03 xiazen

We changed LightInject provider, so I am not sure if it was fixed or not. Probably you should close it until further developments.

n-sidorov avatar Mar 19 '19 11:03 n-sidorov

Thanks, @n-sidorov

ReubenBond avatar Mar 19 '19 15:03 ReubenBond