Total Pageviews

Search This Blog

Loading...

Wednesday, June 24, 2015

Troubleshooting IIS WCF Service Error Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

Greetings!

In one of my Ax/Biztalk/Oracle integration projects, I had to write a web service to retrieve data from Oracle and as part of that development, I was using the Enterprise Library from Microsoft, On my development box, the build was good and my VS project compiles successfully without any issues.

However, while hosting the webservice on IIS 8.0 (Windows Server 2012)  and trying to browse from the internet explorer, I got this error below:

Error:

Server Error in '/' Application.


Could not load file or assembly 'Framework.Data' 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 'Framework.Data' 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 'Framework.Data' 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 'Framework.Data' 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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'Framework.Data' 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) +12480704
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +499
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +131
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'Framework.Data' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12601936
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159


Solution:

After some troubleshooting, found the fix is to set Enable 32-bit Application = True on the App Pool which is used by the webservice. This solved the problem.









Troubleshoot Dynamics AX 2012 AIF Error The deployment web site was not found for the port

I was working on a custom service which I needed to activate on HTTP adapter, however was constantly hitting on this error while activating the service

Error - The deployment web site was not found for port


Fix -

The solution was to remove the end slash (\) from the service uri

System Administration > Setup > AIF > Website

Before: http://localhost:85/MicrosoftDynamicsAXAif60\

After: http://localhost:85/MicrosoftDynamicsAXAif60



I followed this blog which helped me to fix the issue
http://axaptapeople.blogspot.com.au/2013/11/ax2012-aif-known-issues.html



Saturday, June 13, 2015

Book Review - Dynamics AX 2012 R3 Development Cookbook

Dear Friends,

Hope you are having a good time.

Thanks to Velinda from Packt Publishing for providing me with yet another copy of cookbook for review.

Introduction

Microsoft Dynamics AX 2012 R3 Development Cookbook is a handy and a must have book for any developer who is working on AX 2012 R3. It provides with practical scenarios which a developer comes across in his/her day to day work.






About the Author

Mindaugas Pociusis currently a freelance Dynamics AX technical and functional consultant and trainer at DynamicsLab Limited (www.dynamicslab.com). 

He is a Certified Microsoft Trainer for Dynamics AX and has delivered numerous Dynamics AX trainings.Mindaugas has participated in over 20 Dynamics AX implementations. He has held a wide range of development, consulting, and lead roles while always maintaining the significant role of a business application developer.
In December 2009, he released his first book, Microsoft Dynamics AX 2009 Development Cookbook, and then in May 2012, its second edition, Microsoft Dynamics AX 2012 Development Cookbook, both of which are published by Packt Publishing.

In order to obtain a copy of the book, please visit this link


Book Chapters

This book covers the following chapters

Chapter 1 - Processing Data

This chapter covers various scenarios like creating number sequence, merging records, renaming primary key, Executing Direct SQL Statement, Import/Export data from XML file, Building query objects.

Chapter 2 - Working with Forms

This chapter covers topics like using a tree control, Building a checklist form, Creating dialogs using the Runbase framework, Building a dynamic form through code etc

Chapter 3 - Working with Data in Forms

This chapter explains how to create custom filter control, preload images, create a wizard, processing multiple records, Adding image to records.

Chapter 4 - Building Lookups

This chapter is all about lookups - creating a lookup dynamically, using a form to build a lookup, Building a tree lookup and so on.

Chapter 5 - Processing Business Tasks

This chapter walks through various application scenarios like using segmented journal entry control, creating a general journal, posting a general journal, Processing Project Journal, Creating and Posting a Ledger Voucher, Creating and Posting Purchase Order, Creating and Posting Sales Order.

Chapter 6 - Integration with Microsoft Office

This chapter briefs on the various integration scenarios with Microsoft Office Products

Chapter 7 - Using Services

This chapter is all about creating and extending services (AIF and custom services) in Dynamics AX

Chapter 8 - Improving Development Efficiency

This chapter is about building extensions for Code Editor and Personalization forms

Chapter 9 - Improving Dynamics AX Performance

This chapter demonstrates the tools used to troubleshoot AX Performance like Dynamics AX Trace Parser, Calculating code execution time, Using SQL Server Database Engine Tuning Advisor.

Overall, a good book with plenty of code snippets which can be used on a daily basis.

Sunday, June 7, 2015

How to uninstall Windows Internal database for Windows Sharepoint Services 3.0

Greetings All!

It's been a while since I was last here. I was away for a while to meet some personal commitments and also my work life kept me busy.

I would like to share a recent experience where I had to troubleshoot a WSS 3.0 installation where it was using Windows Internal database instead of SQL

I found this technet article helpful to uninstall Windows Internal database

 https://technet.microsoft.com/en-us/library/cc708610(v=ws.10).aspx

Hope it might help somebody out there!

Thursday, March 5, 2015

How to consume ABN (Australian Business Number) or ACN web services from AX 2012 R3

Dear Friends,

Greetings!

Have been super busy with so much to do in so less time!

However, I wanted to take some time and post about my recent experience on how I went integrating ABN Web Service with AX 2012 R3 CU8.

In Australia, we have a concept of ABN and ACN numbers for business registration. ABN is for Australian Business Number and ACN is for Australian Company Number. These registrations are governed by ABR as they are the authority to issue the registration numbers and they maintain this database.

Now, let's get started.

First thing, you would need to go to the ABR site and register to use their webservices.
http://abr.business.gov.au/Webservices.aspx

Once the application is processed which happens within an hour they will e-mail you an authentication GUID (Globally Unique Identifier) which is required to access the ABN Lookup web services. Also with the email, they will send you a pdf which shows you how to access the webservice through various clients like C#, Java, VB6, MS Access etc

Next step, is to open Visual Studio, create a Windows Class Library project and reference the web service. Note, since this is classic web service (.asmx based), so just consume it via the web references node as shown

Web Reference - http://abr.business.gov.au/AbrXmlSearch/AbrXmlSearch.asmx?wsdl













Once this is done, next step is to deploy the Project to AOT (as shown below).




Now, back in AX you should be able to see your deployed project






























Now, let's write some code.. Here is a simple job which I have used to pass a valid ACN number and it returns me the organisation name.

Output: