我使用Kephas,在创建MEF组合容器时会出现问题,如下例所示:
var ambientServicesBuilder = new AmbientServicesBuilder();
IAppManager appManager = null;
var appContext = new AppContext();
var elapsed = await Profiler.WithStopwatchAsync(
async () =>
{
await ambientServicesBuilder
.WithNLogManager()
.WithNetAppRuntime()
// the next line triggers the exception
.WithMefCompositionContainerAsync();
appManager = ambientServicesBuilder.AmbientServices.CompositionContainer.GetExport<IAppManager>();
await appManager.InitializeAppAsync(appContext);
});似乎没有找到"Kephas.Core.resources“。有什么想法吗?
发布于 2017-11-06 11:35:25
这个问题似乎没有出现在.NET 4.5Framework上。下面提供了一个解决方法,确保在初始化环境服务之前将其放置:
AssemblyLoadContext.Default.Resolving += (context, name) =>
{
if (name.Name.EndsWith(".resources"))
{
return null;
}
// do other stuff, like throwing exceptions.
return null;
};注意,这将在运行时禁用异常,但是在设计时仍然会抛出异常,但不会影响程序的执行。
https://stackoverflow.com/questions/47135974
复制相似问题