unity-container - 统一错误 : The given assembly name or codebase was invalid

标签 unity-container mstest

我正在使用微软统一框架工作并收到此错误:

********** 4/15/2012 9:46:08 AM **********
Inner Exception Type: System.IO.FileLoadException
Inner Exception: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Inner Source: mscorlib
Inner Stack Trace: 
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
   at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.TypeResolverImpl.SearchAssemblies(String typeNameOrAlias)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.TypeResolverImpl.ResolveTypeThroughSearch(String typeNameOrAlias)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.TypeResolverImpl.ResolveTypeInternal(String typeNameOrAlias)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.TypeResolverImpl.ResolveType(String typeNameOrAlias, Boolean throwIfResolveFails)
   at Microsoft.Practices.Unity.Configuration.SectionExtensionElement.GetExtensionObjectType()
   at Microsoft.Practices.Unity.Configuration.SectionExtensionElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.DeserializableConfigurationElement.Deserialize(XmlReader reader)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.ConfigurationElementExtensions.ReadUnwrappedElement[TElementType](ConfigurationElement baseElement, XmlReader reader, DeserializableConfigurationElementCollectionBase`1 elementCollection)
   at Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.DeserializeSectionExtension(XmlReader reader)
   at Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.<.cctor>b__5(UnityConfigurationSection s, XmlReader xr)
   at Microsoft.Practices.Unity.Configuration.ConfigurationHelpers.UnknownElementHandlerMap`1.ProcessElement(TContainingElement parentElement, String elementName, XmlReader reader)
   at Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.OnDeserializeUnrecognizedElement(String elementName, XmlReader reader)
   at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
   at System.Configuration.ConfigurationSection.DeserializeSection(XmlReader reader)
   at Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.DeserializeSection(XmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
   at System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
Exception Type: System.Configuration.ConfigurationErrorsException
Exception: An error occurred creating the configuration section handler for unity: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) (C:\Calico\CDT\Dev\CalicoEnergy\EIS.Application.ManinboundedContext.Tests.Integration\bin\Debug\TestResults\Cameron_CAMERON-ENVYPC 2012-04-15 09_46_06\Out\EIS.Application.ManinboundedContext.Tests.Integration.dll.config line 15)
Source: UnityContainer().LoadConfiguration()
Stack Trace: 
   at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   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.Unity.Configuration.UnityContainerExtensions.LoadConfiguration(IUnityContainer container)
   at EIS.Application.ManinboundedContext.Tests.Integration.DemandResponesAppServiceIntegrationTests.InitializeTesting(TestContext context) in C:\Calico\CDT\Dev\CalicoEnergy\EIS.Application.ManinboundedContext.Tests.Integration\DemandResponesAppServiceIntegrationTests.cs:line 48

我知道我错过了一个集会。如何确定我缺少什么程序集?我正在运行 mstest 项目。我尝试了程序集绑定(bind)查看器,但没有结果。我已将所有程序集的引用添加到我的测试项目中。我该如何解决这个问题? Unity 不会告诉我缺少什么程序集。

最佳答案

我无法让 fuslogvw 向我展示缺少哪些组件。



通过在我的测试项目的 bin\debug 目录和 mstest 创建的目录之间进行比较来进行比较,以使用 (\TestResults\My Machine Name 2012-04-23 09_22_24\Out) 执行测试,我能够识别缺少的程序集。

我不知道 mstest 正在构建一个新目录并且没有选择一些被注入(inject)的类型。一旦我发现 MSTest 正在创建自己的目录,我就能够通过差异来找到问题。

供引用。缺少的是企业库类型。

关于unity-container - 统一错误 : The given assembly name or codebase was invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10164803/

相关文章:

c# - 您如何对旨在与数据对话的类进行单元测试?

c# - MSTest VS2010 - DeploymentItem 将文件复制到不同机器上的不同位置

unity-container - 使用哪一个 : unity interception or policy injection

c# - 如何在统一的 XML 配置中将一个单例注册到不同的接口(interface)?

c# - 有没有什么好的方法可以在 Unity 中使用事件?

c# - 如何使用 mstest 将输出文件添加到结果窗口?

c# - MSTest 超时属性未按预期工作

visual-studio-2010 - 从 TFS2010 Team Build 运行 VS2012 单元测试

c# - RegisterType 与 UnityContainer 中的接口(interface)

.net - 团结 : how to resolve class through base interface