如何解决"无法加载文件或程序集“Microsoft.P​​ractices.Prism'"错误? [英] How to resolve "Could not load file or assembly 'Microsoft.Practices.Prism' " error?

查看:924
本文介绍了如何解决"无法加载文件或程序集“Microsoft.P​​ractices.Prism'"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找过去几天试图让固定用棱镜WPF应用程序错误,但还没有任何运气,我想我会看看是否有#1任何想法。请注意,我绝对是一个菜鸟,当涉及到棱镜一般:)



我在学习如何创建一个使用棱镜的应用程序的过程中,随着团结是选择我的依赖注入容器。我试图加载使用修改App.config文件模块,但我得到相关的引导程序运行时错误。错误信息会比任何解释,我可以提供更准确,所以我已经包括App.config文件,这里的错误是出现App.xaml.cs文件,下面的错误信息。



感谢您提前为任何见解,您可以提供,并让我知道如果有您可能需要的任何额外信息!



修改:在错误引用此文件目录(C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config 4号线)指App.config文件的第四行(段名称= ...)。所有我发现教程和引用是一样的我有什么,但是这仍然是造成它似乎问题就行了。



编辑2 :在第一个编辑引用的行实际上是完全一样的官方什么的微软棱镜指南



修改3 :所以我也没搞清楚,根是什么造成了这一点,但在我的无奈我重新启动项目的例子我是通过工作,在新的项目中我没有得到错误。还是不知道问题的根源是,虽然



修改4 :只是开玩笑,同样的错误是早在新的方案。






App.config中:

 <?XML版本=1.0编码=UTF-8>?; 
<结构>
< configSections>
<节名称=模块式=Microsoft.P​​ractices.Prism.Modularity.ModulesConfigurationSection,Microsoft.P​​ractices.Prism/>
< / configSections>

<模块>
<模块assemblyFile =EmailModule.dllmoduleType =EmailService.ModuleDefinitions.Module,EmailService,版本= 1.0.0.0,文化=中立,公钥=空MODULENAME =EmailModulestartupLoaded =真/ >
< /模块>


<&启动GT;
< supportedRuntime版本=V4.0SKU =.net框架,版本= V4.5/>
< /启动>
< /结构>

在出现




App.xaml.cs(错误bootstrapper.Run()行):

 使用系统; 
使用System.Collections.Generic;
使用System.Configuration;
使用System.Data这;
使用System.Linq的;使用System.Threading.Tasks
;使用System.Windows
;

命名空间EmailCli​​ent
{
///<总结> $ B $为App.xaml中
///< b ///交互逻辑; /总结>
公共部分类应用:应用
{
保护覆盖无效OnStartup(StartupEventArgs E)
{
base.OnStartup(E);

MyBootstrapper引导程序=新MyBootstrapper();
bootstrapper.Run();
}
}
}






错误消息:




System.Configuration.ConfigurationErrorsException了未处理
HResult的= -2146232062
留言=出错创建模块的配置节处理程序:无法加载文件或程序集Microsoft.P​​ractices.Prism或它的一个依赖。该系统找不到指定的文件。 (C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config 4号线)
来源= System.Configuration
BareMessage =出错创建模块的配置节处理程序:无法加载文件或程序集Microsoft.P​​ractices.Prism或它的一个依赖。该系统找不到指定的文件。
文件名= C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config
线= 4
堆栈跟踪:在System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(字符串configKey,布尔和放大器; isRootDeclaredHere)

在System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串configKey,布尔getLkg,布尔的checkPermission,布尔getRuntimeObject,布尔requestIsHere,对象和放大器;因此,对象和放大器; resultRuntimeObject)
在System.Configuration.BaseConfigurationRecord.GetSection(字符串configKey)
在System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(字符串sectionName)$ b在System.Configuration.ConfigurationManager.GetSection(字符串sectionName)
在Microsoft.P​​ractices.Prism.Modularity.ConfigurationStore.RetrieveModuleConfigurationSection()
。在Microsoft.P​​ractices.Prism.Modularity.ConfigurationModuleCatalog.EnsureModulesDiscovered $ b()
在Microsoft.P​​ractices.Prism.Modularity.ConfigurationModuleCatalog.InnerLoad()
在Microsoft.P​​ractices.Prism.Modularity.ModuleCatalog.Load()
在Microsoft.P​​ractices.Prism.Modularity.ModuleCatalog .Initialize()
在Microsoft.P​​ractices.Prism.Modularity.ModuleManager.Run()在Microsoft.P​​ractices.Prism.UnityExtensions.UnityBootstrapper.InitializeModules
()
在Microsoft.P​​ractices.Prism .UnityExtensions.UnityBootstrapper.Run(布尔runWithDefaultConfiguration)
在Microsoft.P​​ractices.Prism.Bootstrapper.Run()
在EmailCli​​ent.App.OnStartup(StartupEventArgs E)在C:\Users\Roger\\ \\Documents\TestPrismProject\WpfApplication1\WpfApplication1\App.xaml.cs:第21行$ b $ LT b。在System.Windows.Application&; .ctor> b__1(对象未用)
在System.Windows。 .Threading.ExceptionWrapper.InternalRealCall(委托回调,对象指定参数时,的Int32 numArgs)
在MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象指定参数时,的Int32 numArgs,代表catchHandler)
在System.Windows.Threading.DispatcherOperation.InvokeImpl()
在System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(对象状态)
在System.Threading.ExecutionContext.RunInternal(ExecutionContext中的ExecutionContext,ContextCallback回调,对象状态,布尔preserveSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回调,对象状态,布尔preserveSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回调,对象状态)
在System.Windows.Threading.DispatcherOperation.Invoke()
在System.Windows.Threading.Dispatcher.ProcessQueue()
在System.Windows.Threading.Dispatcher.WndProcHook(IntPtr的HWND,味精的Int32,IntPtr的的wParam,lParam中的IntPtr,布尔和放大器;处理)
在MS.Win32.HwndWrapper.WndProc(IntPtr的HWND,味精的Int32,IntPtr的的wParam,lParam中的IntPtr,布尔和放大器;处理)
在MS.Win32.HwndSubclass.DispatcherCallbackOperation(对象o)
。在System.Windows.Threading.ExceptionWrapper.InternalRealCall(代表回调,对象指定参数时,的Int32 numArgs)
在MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(对象源,委托方法,对象指定参数时,的Int32 numArgs,代表catchHandler )在System.Windows.Threading.Dispatcher.LegacyInvokeImpl(优先级的DispatcherPriority,时间跨度超时,代表法,对象ARGS
,的Int32 numArgs)
在MS.Win32.HwndSubclass.SubclassWndProc(IntPtr的HWND,味精的Int32, IntPtr的的wParam,lParam的的IntPtr)
在MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG&安培;味精)
在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame帧)
在System.Windows。在System.Windows.Threading.Dispatcher.Run Threading.Dispatcher.PushFrame(DispatcherFrame帧)
()
在System.Windows.Application.RunDispatcher(对象忽略)
在System.Windows。 Application.RunInternal在(窗口的窗口)
在System.Windows.Application.Run(窗口窗口)
在System.Windows.Application.Run()
在EmailCli​​ent.App.Main() C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\obj\Debug\App.g.cs:行50
的InnerException信息:System.IO.FileNotFoundException
=的HResult -2147024894
消息=无法加载文件或程序集Microsoft.P​​ractices.Prism或它的一个依赖。该系统找不到指定的文件。
来源= System.Configuration
=文件名Microsoft.P​​ractices.Prism
FusionLog ====预绑定状态信息===
日志:显示名称= Microsoft.P​​ractices.Prism
(部分)
警告:部分绑定信息是为组装供应:
WRN:大会名称:Microsoft.P​​ractices.Prism |域ID:1
警告:如果仅提供集显示名称的一部分发生了一个部分绑定。
警告:这可能会导致粘合剂加载了不正确的装配。
警告:建议提供装配,
WRN完全指定文字的身份:一个由简单的名称,版本,区域性和公钥令牌。
警告:请参见白皮书 http://go.microsoft.com/fwlink/?LinkId = 109270 获得更多的信息和对这个问题的共同解决方案。
日志:应用平台=文件:/// C:/用户/罗杰/文件/ TestPrismProject / WpfApplication1 / WpfApplication1 /斌/调试/
日志:初始PrivatePath = NULL
调用汇编:系统.Configuration,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a。
日志:此绑定的默认加载上下文开始。
日志:使用应用程序配置文件:C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config
日志:使用主机配置文件:
日志:使用从C机配置文件:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config。
日志:没有被应用政策在这个时候(私人,自定义,局部的,或基于位置的程序集绑定)来引用。
日志:尝试新的URL文件下载:/// C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.P​​ractices.Prism.DLL。
日志:尝试新的URL文件下载:/// C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.P​​ractices.Prism/Microsoft.P​​ractices.Prism.DLL。
日志:尝试新的URL文件下载:/// C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.P​​ractices.Prism.EXE。
日志:尝试新的URL文件下载:/// C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.P​​ractices.Prism/Microsoft.P​​ractices.Prism.EXE




 堆栈跟踪:
在System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost主机,字符串typestring,设定布尔throwOnError)
在System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord,FactoryRecord factoryRecord)
在System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord,FactoryRecord factoryRecord)
。在System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(factoryRecord factoryRecord)
在System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(字符串configKey,布尔和放大器; isRootDeclaredHere)
的InnerException:


解决方案

解决方案结束了简单的,因为这些东西往往是...我没有改变我的应用程序以资源(可通过​​点击App.config文件并查看属性部分中找到)config文件的生成操作。


I've been searching the past few days trying to get an error fixed in a WPF application using Prism, but haven't had any luck and thought I'd see if Stackoverflow had any ideas. Please note, I'm definitely a noob when it comes to Prism in general :)

I'm in the process of learning how to create an application using Prism, with Unity being my dependency injection container of choice. I'm trying to load modules using a modified App.config file, but I'm getting a runtime error related to the bootstrapper. The error messages will be more accurate than any explanation I can provide, so I've included the App.config file, App.xaml.cs file where the error is appearing, and the error information below.

Thank you in advance for any insight you can provide, and let me know if there's any additional information you might need!

EDIT: This file directory referenced in the error (C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config line 4) refers to the fourth line of App.config file (section name= ...). All the tutorials and references I've found are the same as what I have, but this is still the line that's causing issues it seems.

EDIT 2: The line referenced in the first edit is actually exactly the same as what's on the official Microsoft Prism guide.

EDIT 3: So I never did figure out the root of what was causing this, but in my frustration I restarted the example project I was working through and am not getting the error in the new project. Still not sure what the root of the problem was though.

EDIT 4: Just kidding, the same error is back in the new program.


App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="modules" type="Microsoft.Practices.Prism.Modularity.ModulesConfigurationSection, Microsoft.Practices.Prism"/>
  </configSections>

  <modules>
    <module assemblyFile="EmailModule.dll" moduleType="EmailService.ModuleDefinitions.Module, EmailService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="EmailModule" startupLoaded="true" />
  </modules>


  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
</configuration>


App.xaml.cs (error appears on the "bootstrapper.Run()" line):

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace EmailClient
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            MyBootstrapper bootstrapper = new MyBootstrapper();
            bootstrapper.Run();
        }
    }
}


Error Message:

System.Configuration.ConfigurationErrorsException was unhandled HResult=-2146232062 Message=An error occurred creating the configuration section handler for modules: Could not load file or assembly 'Microsoft.Practices.Prism' or one of its dependencies. The system cannot find the file specified. (C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config line 4) Source=System.Configuration BareMessage=An error occurred creating the configuration section handler for modules: Could not load file or assembly 'Microsoft.Practices.Prism' or one of its dependencies. The system cannot find the file specified. Filename=C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config Line=4 StackTrace: at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at Microsoft.Practices.Prism.Modularity.ConfigurationStore.RetrieveModuleConfigurationSection() at Microsoft.Practices.Prism.Modularity.ConfigurationModuleCatalog.EnsureModulesDiscovered() at Microsoft.Practices.Prism.Modularity.ConfigurationModuleCatalog.InnerLoad() at Microsoft.Practices.Prism.Modularity.ModuleCatalog.Load() at Microsoft.Practices.Prism.Modularity.ModuleCatalog.Initialize() at Microsoft.Practices.Prism.Modularity.ModuleManager.Run() at Microsoft.Practices.Prism.UnityExtensions.UnityBootstrapper.InitializeModules() at Microsoft.Practices.Prism.UnityExtensions.UnityBootstrapper.Run(Boolean runWithDefaultConfiguration) at Microsoft.Practices.Prism.Bootstrapper.Run() at EmailClient.App.OnStartup(StartupEventArgs e) in c:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\App.xaml.cs:line 21 at System.Windows.Application.<.ctor>b__1(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at EmailClient.App.Main() in c:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\obj\Debug\App.g.cs:line 50 InnerException: System.IO.FileNotFoundException HResult=-2147024894 Message=Could not load file or assembly 'Microsoft.Practices.Prism' or one of its dependencies. The system cannot find the file specified. Source=System.Configuration FileName=Microsoft.Practices.Prism FusionLog==== Pre-bind state information === LOG: DisplayName = Microsoft.Practices.Prism (Partial) WRN: Partial binding information was supplied for an assembly: WRN: Assembly Name: Microsoft.Practices.Prism | Domain ID: 1 WRN: A partial bind occurs when only part of the assembly display name is provided. WRN: This might result in the binder loading an incorrect assembly. WRN: It is recommended to provide a fully specified textual identity for the assembly, WRN: that consists of the simple name, version, culture, and public key token. WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. LOG: Appbase = file:///C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/ LOG: Initial PrivatePath = NULL Calling assembly : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Roger\Documents\TestPrismProject\WpfApplication1\WpfApplication1\bin\Debug\WpfApplication1.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.Practices.Prism.DLL. LOG: Attempting download of new URL file:///C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.Practices.Prism/Microsoft.Practices.Prism.DLL. LOG: Attempting download of new URL file:///C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.Practices.Prism.EXE. LOG: Attempting download of new URL file:///C:/Users/Roger/Documents/TestPrismProject/WpfApplication1/WpfApplication1/bin/Debug/Microsoft.Practices.Prism/Microsoft.Practices.Prism.EXE.

   StackTrace:
        at System.Configuration.TypeUtil.GetTypeWithReflectionPermission(IInternalConfigHost host, String typeString, Boolean throwOnError)
        at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
        at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
        at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
        at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
   InnerException: 

解决方案

The solution ended up being simple, as these things often are... I hadn't changed my App.config file's Build Action to "Resource" (can be found by clicking on the App.config file and looking at the properties section).

这篇关于如何解决&QUOT;无法加载文件或程序集“Microsoft.P​​ractices.Prism'&QUOT;错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆