Total Pageviews

Search This Blog

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!