相关疑难解决方法(0)

无法解析使用可移植类库的程序集

我在最终用户机器上遇到装配解决问题,我相信它与使用便携式类库有关....

我有一个最初用Visual Studio 2010编写的.NET 4.0应用程序.最近我们升级到Visual Studio 2012,我们创建了一些可移植类库的项目.我不认为我们现在需要这些功能,但我们也在构建可能从这些库中受益的Windows 8 Store应用程序.

当我编译项目时,便携式库功能到底有什么作用?我希望它允许我在不修改或重新编译的情况下在不同的框架上运行它.

当我在反射器 dotPeek中查看库时,它将Platform属性显示为:

.NETPortable,版本= 4.0版,档案=规范5

参考文献似乎是2.0-ish:

mscorlib,版本= 2.0.5.0

系统,版本= 2.0.5.0

System.Runtime.Serialization,Version = 2.0.5.0

当我在这个最终用户的机器上运行应用程序时,我在日志文件中看到一个错误:

无法加载文件或程序集,'System.Core,Version = 2.0.5.0 ......'

谷歌搜索System.Core 2.0.5.0似乎是指SilverLight - 它似乎是目标框架之一.

本机没有安装Visual Studio,但有.NET 4.0(4.0.3更新)

有什么我应该做的不同编译,我应该调查我的依赖项或我应该在最终用户机器上安装的东西?2.0.5.0引用了什么?

.net-4.0 portable-class-library

15
推荐指数
1
解决办法
7704
查看次数

尝试将Autofac加载为嵌入式程序集时出现FileNotFoundException

早期版本的Autofac工作,但由于他们切换到使其成为可移植类库,它将无法加载.

我尝试应用此处列出的修复程序(KB2468871),但它告诉我它不需要.

当我将Autofac.dll文件移动到与可执行文件相同的位置时,错误消失了.当它从外部DLL加载它时,它加载正常.

为什么它不能作为嵌入式DLL工作?

这是一个例外:

        System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.

        Stack trace: 
           at Autofac.Core.Registration.ComponentRegistration..ctor(Guid id, IInstanceActivator activator, IComponentLifetime lifetime, InstanceSharing sharing, InstanceOwnership ownership, IEnumerable`1 services, IDictionary`2 metadata)
           at Autofac.Core.Container..ctor()
           at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
           at MyApp.Configuration.Bootstrapper.Run(String[] args) in c:\Dev\MyApp\App\Configuration\Bootstrapper.cs:line 25
           at MyApp.Configuration.EntryPoint.Main(String[] args) in c:\Dev\MyApp\App\Configuration\EntryPoint.cs:line 22
Run Code Online (Sandbox Code Playgroud)

如果有帮助,这里是.csproj文件的一部分,它将DLL嵌入到可执行文件中:

  <Target Name="AfterResolveReferences">
<ItemGroup>
  <EmbeddedResource Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
    <LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
  </EmbeddedResource>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

...这里是EntryPoint类:

internal static …
Run Code Online (Sandbox Code Playgroud)

c# dll embedded-resource

9
推荐指数
1
解决办法
3256
查看次数