AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 12.12.2014, 19:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
emeadaxsupport: Error when browsing a custom service hosted as IIS web service: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Источник: http://blogs.msdn.com/b/axsupport/ar...x8007000b.aspx
==============

Title: Error when browsing a custom service hosted as IIS web service - An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Scenario:

You are using Microsoft Dynamics AX 2012
You have created several Custom Services that you can deploy using NetTcp successfully and consume the WSDL in your client applications without any errors.

You can deploy the same Custom Services in an enhanced port, using the HTTP adapter (to host as IIS Web Services).
However when you try and browse to the service you get an error similar to the below:

Server Error in '/MicrosoftDynamicsAXAif60' Application.
--------------------------------------------------------------------------------
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

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: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

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.
Stack Trace:

[BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)]
System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType) +0
System.Reflection.RuntimeMethodInfo.get_Signature() +82
System.Reflection.RuntimeMethodInfo.GetParameters() +38
System.Runtime.Serialization.ClassDataContractCriticalHelper.EnsureMethodsImported() +189
System.Runtime.Serialization.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) +786
System.Runtime.Serialization.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type) +117
System.Runtime.Serialization.XsdDataContractExporter.GetSchemaTypeName(Type type) +85
System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter..ctor(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory) +413
System.ServiceModel.Description.DataContractSerializerOperationBehavior.GetFormatter(OperationDescription operation, Boolean& formatRequest, Boolean& formatReply, Boolean isProxy) +308
System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IOperationBehavior.ApplyDispatchBehavior(OperationDescription description, DispatchOperation dispatch) +69
System.ServiceModel.Description.DispatcherBuilder.BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) +120
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +4122
System.ServiceModel.ServiceHostBase.InitializeRuntime() +90
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +182
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +742
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +126
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +901
[ServiceActivationException: The service '/MicrosoftDynamicsAXAif60//xppservice.svc' cannot be activated due to an exception during compilation. The exception message is: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).]
System.Runtime.AsyncResult.End(IAsyncResult result) +650220
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210733
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +166


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18055



Possible Causes:

Cause 1:

One possible reason can be that the Custom Services Data contract classes contain other methods referencing types that are not part of the service/data contract. Data contract classes are only meant to have parm methods that are the data members. So when deploying the service to IIS, the modules containing these other types are not included and the types do not load.

When generating service classes, we only parse the public service and data contracts. We expect that data contracts are just containers for passing data around and do not have a dependency on non-service contract types. When deploying to IIS, we only copy the types that are part of the contract. This has always been the design for using data contracts in Services and AIF.



Resolution:
To resolve this, re-view your service contracts and refactor the code to remove all methods from data contracts that are not data members and rewire them, and redeploy the service to IIS again.



More information:
The reason why we don't experience the same behaviour when consuming the Custom Services over NetTcp is that NetTcp is hosted on the AOS where all data types and NetModules are available and it manages to resolve the other data types. The real solution is to ensure that Data contract classes only have parm methods that are the data members.

Further info on using Data Contracts in X++ can be found at http://technet.microsoft.com/library/gg848068.aspx



Cause 2:

Assuming the data contract services are all valid and you are running Microsoft Dynamics AX 2012 R2 with application build 6.2.1000.4051 (CU-7) or lower than download Application hotfix KB2934017 and test it, see Apply updates
and hotfixes [AX 2012]





Источник: http://blogs.msdn.com/b/axsupport/ar...x8007000b.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
atinkerersnotebook: Using Service Management to Track Service Orders Blog bot DAX Blogs 1 25.08.2013 19:16
AIF: Microsoft Dynamics AX Services and Windows Azure Service Bus Blog bot DAX Blogs 0 24.07.2013 03:13
Microsoft Dynamics CRM Team Blog: Creating and Publishing a Web Portal to an Azure Cloud Service Blog bot Dynamics CRM: Blogs 0 17.04.2013 23:11
emeadaxsupport: AX for Retail 2012 R2: Troubleshooting the Real-time Service Blog bot DAX Blogs 0 31.12.2012 11:13
emeadaxsupport: AX for Retail 2012 R2: Installing the Real-time Service Blog bot DAX Blogs 0 19.12.2012 11:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 15:44.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.