无法加载文件或程序集'sapnco'或其依赖项之一。 Se ha intentado cargar un programa con un formato wrongo

时间:2013-11-08 11:13:37

标签: c# wcf sap

我是闷棍新手。我正在使用带有项目4.0的sapconector。 我是一个名为A的课程项目,我使用这个dll:sapnco和sapnco_utils。

另外,我是一个WCF项目。在这个项目中,我添加了A的项目参考。 我调试了我的WCF,项目右侧的按钮 - >调试 - >启动新实例,我收到此错误。

我该怎么办? 感谢!!!

Server Error in '/' Application.

Could not load file or assembly 'sapnco' or one of its dependencies. Se ha intentado cargar un programa con un formato incorrecto.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'sapnco' or one of its dependencies. Se ha intentado cargar un programa con un formato incorrecto.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'sapnco' could not be loaded.


Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = YAESMIO\svcwss
LOG: DisplayName = sapnco
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: sapnco | Domain ID: 2
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:/Yaesmio/Yaesmio!/Servicios/Yaesmio.Servicios.RegistroService.Registro/
LOG: Initial PrivatePath = C:\Yaesmio\Yaesmio!\Servicios\Yaesmio.Servicios.RegistroService.Registro\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Yaesmio\Yaesmio!\Servicios\Yaesmio.Servicios.RegistroService.Registro\web.config
LOG: Using host configuration file: C:\Users\svcwss\Documents\IISExpress\config\aspnet.config
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:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d835eea5/b147a9f9/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d835eea5/b147a9f9/sapnco/sapnco.DLL.
LOG: Attempting download of new URL file:///C:/Yaesmio/Yaesmio!/Servicios/Yaesmio.Servicios.RegistroService.Registro/bin/sapnco.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'sapnco' or one of its dependencies. Se ha intentado cargar un programa con un formato incorrecto.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'sapnco' or one of its dependencies. Se ha intentado cargar un programa con un formato incorrecto.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +124
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +44
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +187
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +74
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
   System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) +82
   System.Web.Compilation.BuildManager.GetCompiledCustomString(String virtualPath) +29
   System.ServiceModel.HostingManager.GetCompiledCustomString(String normalizedVirtualPath) +164
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +206
   System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +52
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598

[ServiceActivationException: The service '/ServicioRegistro.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not load file or assembly 'sapnco' or one of its dependencies. Se ha intentado cargar un programa con un formato incorrecto..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +495736
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178
   System.ServiceModel.Activation.ServiceHttpHandler.EndProcessRequest(IAsyncResult result) +6
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129

2 个答案:

答案 0 :(得分:0)

您的程序集是否已正确设置。您使用.Net SDK的连接器版本也是如此。 VS2010需要3.0,2012年需要nCo 4

答案 1 :(得分:0)

如果使用64位dll,请尝试使用32位dll,而不是64位。这对我有用。