首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我得到了System.IO.FileNotFoundException:“无法加载指定的文件。”在.NET核心上创建组合容器时

我得到了System.IO.FileNotFoundException:“无法加载指定的文件。”在.NET核心上创建组合容器时
EN

Stack Overflow用户
提问于 2017-11-06 11:29:57
回答 1查看 290关注 0票数 0

我使用Kephas,在创建MEF组合容器时会出现问题,如下例所示:

代码语言:javascript
复制
        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“。有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-06 11:35:25

这个问题似乎没有出现在.NET 4.5Framework上。下面提供了一个解决方法,确保在初始化环境服务之前将其放置:

代码语言:javascript
复制
        AssemblyLoadContext.Default.Resolving += (context, name) =>
            {
                if (name.Name.EndsWith(".resources"))
                {
                    return null;
                }

                // do other stuff, like throwing exceptions.
                return null;
            };

注意,这将在运行时禁用异常,但是在设计时仍然会抛出异常,但不会影响程序的执行。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47135974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档