无法加载文件或程序集'Version = 3.0.1.0,PublicKeyToken = null或其依赖项之一。需要具有强名称的程序集。

时间:2013-05-04 18:25:17

标签: c# asp.net-mvc visual-studio .net-assembly

在我的应用程序中给予程序集强大的密钥名称,包括带有VS 2012命令提示符的第三方DLL,我得到程序集加载错误。

Could not load file or assembly ', Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)



FileLoadException: Could not load file or assembly 'ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)] 

  System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType) +0 `System.Reflection.RuntimeMethodInfo.get_ReturnType() +42 `System.Web.HttpApplicationFactory.ReflectOnMethodInfoIfItLooksLikeEventHandler(MethodInfo m) +19` 
System.Web.HttpApplicationFactory.ReflectOnApplicationType() +374


System.Web.HttpApplicationFactory.CompileApplication() +143` System.Web.HttpApplicationFactory.EnsureInited() +80
   System.Web.HttpApplicationFactory.SetupFileChangeNotifications() +67
   System.Web.Compilation.BuildManager.CompileGlobalAsax() +57
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +269`

[HttpException (0x80004005): Could not load file or assembly 'ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)]


 System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +427
System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +530

[HttpException (0x80004005): Could not load file or assembly 'ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)]

 System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +456

我已从所有解决方案中删除了所有bin和obj文件夹,并重建和批量构建,包括清理解决方案也更改了程序集版本,但仍然无法找到确切的错误。

1 个答案:

答案 0 :(得分:1)

上面列出的是混乱的混乱。但是,上周我刚刚遇到这个错误,所以你很幸运。为了使强名称起作用,您需要

  1. 创建密钥
  2. 将密钥添加到程序集文件
  3. 在项目属性中添加签名
  4. 多数民众赞成!所有关于如何做的信息就在这里 http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C

      

    为了公开COM对象,您的类库程序集   还必须有一个强大的名字。要创建强名称,请使用该实用程序   SN.EXE。

         

    折叠|复制代码sn -k Database_COM_Key.snk打开   AssemblyInfo.cs并修改行:

         

    折叠|复制代码[程序集:   AssemblyKeyFile(" Database_COM_Key.snk")]构建对象。构建   也导致一个类型库,可以导入到您的   托管或非托管代码。

    你也可以在这里参考我的问题。