2015-10-20 80 views
1

在我的asp.net mvc應用程序中,我添加了Microsoft.Dynamics.GP.eConnect ,和Microsoft.Dynamics.GP.eConnect.Serialization DLL的。以下是完整的錯誤消息:無法加載文件或程序集'Microsoft.Dynamics.GP.eConnect'或它的一個依賴關係

Could not load file or assembly 'Microsoft.Dynamics.GP.eConnect' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

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 'Microsoft.Dynamics.GP.eConnect' or one of its dependencies. An attempt was made to load a program with an incorrect format. 

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 'Microsoft.Dynamics.GP.eConnect' could not be loaded. 


WRN: Assembly binding logging is turned OFF. 
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. 
Note: There is some performance penalty associated with assembly bind failure logging. 
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. 

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'Microsoft.Dynamics.GP.eConnect' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    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 'Microsoft.Dynamics.GP.eConnect' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +736 
    System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +217 
    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130 
    System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170 
    System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +284 
    System.Web.Compilation.BuildManager.ExecutePreAppStart() +153 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521 

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Dynamics.GP.eConnect' or one of its dependencies. An attempt was made to load a program with an incorrect format.] 
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9931916 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254 

我使用.NET Framework 4.5與econnect的dll的12.0.0.0版本。任何人有任何想法?

回答

0

System.BadImageFormatException異常是這裏的線索。這通常是在32位和64位程序集之間不匹配的情況下。例如,如果IIS以32位模式運行,但解決方案引用64位「Microsoft.Dynamics.GP.eConnect」程序集。

因此,請確保您引用了「Microsoft.Dynamics.GP.eConnect」程序集的正確版本。 64位版本安裝在「C:\ Program Files \ Microsoft Dynamics \ eConnect 12.0 \ API \」中,32位版本位於「C:\ Program Files文件(x86)\ Microsoft Dynamics \ eConnect 12.0 \ API \ 「

相關問題