0

In my application after giving the assemblies strong key names including the third parties DLLs with VS 2012 Command Prompt I get the assembly loading error.

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

I have removed all bin and obj folder from all the solution and rebuild and batch build including cleaned the solution also changed the assembly version and still not able to find the exact error.

Paweł Dziepak
  • 2,062
  • 1
  • 16
  • 17
lioni jordan
  • 169
  • 2
  • 3
  • 8
  • 1
    > [Could not load assembly] after giving the assemblies strong key names: Are all assemblies where your signed assembly depend on (including 3d party assemblies) are signed, too? – k3b May 04 '13 at 19:13
  • I signed other assembles from VS 2012 except the third parties assembly from ilasm and exported them to the solution. – lioni jordan May 04 '13 at 19:31

1 Answers1

2

What you listed above is a jumbled mess. HOWEVER, I just had this error last week so you are in luck. In order for the strong name to work you need to

  1. Create the key
  2. Add the key to the assembly file
  3. In projects properties add signature

Thats it! all of the info on how to do it is right here http://www.codeproject.com/Articles/7859/Building-COM-Objects-in-C

In order for the COM object to be exposed, your class library assembly must also have a strong name. To create a strong name, use the utility SN.EXE.

Collapse | Copy Code sn -k Database_COM_Key.snk Open the AssemblyInfo.cs and modify the line:

Collapse | Copy Code [assembly: AssemblyKeyFile("Database_COM_Key.snk")] Build the object. The build also results into a type library that can be imported into your managed or unmanaged code.

Also you can refer to my question here on stack.

and

Community
  • 1
  • 1
DotNetRussell
  • 9,716
  • 10
  • 56
  • 111
  • I add the strong key name with the code of [assembly: AssemblyKeyFile(@"C:\\\newkey.snk")] in AssemblyInfo.cs and getting the following error: use use command line option keyfile or appropriate project settings instead of 'assemblykeyfile' – lioni jordan May 05 '13 at 15:15
  • It's because this is a deprecated way of doing this. It should still work just fine. – DotNetRussell May 05 '13 at 18:44
  • What I am getting now is: Could not load file or assembly 'ClubStarterKit.Core, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) – lioni jordan May 07 '13 at 17:10
  • http://www.abudhabieuropcar.com/assembly.html is the message I am getting in the assembly log – lioni jordan May 07 '13 at 17:26
  • Could you also please advise on this : http://stackoverflow.com/questions/16425549/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference – lioni jordan May 08 '13 at 15:38