File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found

Imagine.. You're writing a wonderful MS CRM 3.0 addon. After writing lines and lines of code, the time is there to run and test the addon. Instead of seeing your fantasic, state-of-the-art, rocket-science, cutting-edge addon, it is this message that arises:

Parser Error Message: File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found.

Great.

Now how to solve this?

Well, Jonathan Randall has answered that question already in one of the newsgroups. Here's his posting:

The issue is caused because when you place your under application under the Microsoft CRM 3.0 web site, your application inherits the settings from the parent web site. Since the Microsoft CRM application has the two assemblies located in its own \bin folder, Microsoft CRM functions
correctly. However, your application does not have these assemblies in its \bin folder so as a result, the application fails to load. Here is some information that will correct the issue:

Symptoms: When a user attempts to access an ASP.NET web application that has its virtual directory located under the Microsoft CRM v3.0 Web Site in Internet Information Services (IIS), the following error will be displayed:

Server Error in '/' Application.
----------------------------------------------------------------------

Further detail on the error includes the following:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: File or assembly name Microsoft.Crm.MetadataService, or one of its dependencies, was not found.

Source Error:

Line 11: <add assembly="Microsoft.Crm.ManagedInterop, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 12: <add assembly="Microsoft.Crm.MetadataHelper, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 13: <add assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 14: <add assembly="Microsoft.Crm.NativeInteropProxy,
Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 15: <add assembly="Microsoft.Crm.ObjectModel, Version=3.0.5300.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Source File: C:\Program Files\Microsoft CRM\CRMWeb\web.config
Line: 13

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

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===

LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file (C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet.config).
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/f72fefd/Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/ f72fefd/ Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/e724dea7/ f72fefd/Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/kbtest/ e724dea7/ f72fefd/ Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/bin/Microsoft.Crm.MetadataService.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft CRM/CRMWeb/KBTest/ bin/Microsoft.Crm.MetadataService/ Microsoft.Crm.MetadataService.EXE.

----------------------------------------------------------------------------
----
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300

Cause: Since the ASP.NET web application is located under the Microsoft CRM v3.0 web site, the application is inheriting settings that are part of the Microsoft CRM web site's web.config file. The Web.config file for a specific ASP.NET application is located in the root directory of the application and contains settings that apply to the Web application and inherit downward through all of the subdirectories in its branch. In this case, the Microsoft.Crm.MetadataService.dll and the Microsoft.Crm.Tools.ImportExportPublish.dll assemblies are being loaded by the Microsoft CRM web site. These two assemblies are located in the Microsoft CRM web application's \bin directory. Since these two assemblies are not part of the custom ASP.NET application, the Common Language Runtime begins a probing operation to locate the two assemblies. Since the assemblies are not installed into the Global Assembly Cache (GAC) or in the custom ASP.NET application's \bin folder, the exception is thrown.

Resolution:

There are four solutions to resolve the error. Each solution is detailed below.

Solution 1: Remove <add assemblies> entries in Microsoft CRM v3.0 web site's web config file.

In the <system.web> element of the web.config file, locate the <assemblies> node and remove the following entries:
<add assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="Microsoft.Crm.Tools.ImportExportPublish, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

Solution 2: Install the Microsoft.Crm.MetadataService.dll and the Microsoft.Crm.Tools.ImportExportPublish.dll into the Global Assembly Cache (GAC).

The two assemblies that can be added to the Global Assembly Cache are located in the \bin directory under the Microsoft CRM web site's installation folder. A typical location would be C:\Program Files\Microsoft CRM\CRMWeb\bin.

Solution 3: Edit the ASP.NET web application's web config to remove the two Microsoft CRM assemblies.

Edit the ASP.NET application's web.config by adding the following entries to the <compilation> element that is nested in the <system.web> element of the file:

<system.web>
<compilation defaultLanguage="C#" debug="true">
<assemblies>
<remove assembly="Microsoft.Crm.MetadataService, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove assembly="Microsoft.Crm.Tools.ImportExportPublish, Version=3.0.5300.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>

Solution 4: Locate the ASP.NET web application in a separate web site from the Microsoft CRM v3.0 web site.

Using this approach ensures that the application does not inherit any of the settings from the Microsoft CRM web site.

Jonathan Randall
Microsoft Online Support Engineer - MBS CRM Developer Support

8 comments:

Anonymous said...

We always put our custom asp.net files in a folder out of the crmtree. Like stated in the last solution. It works like a charm. Don't know if it would be harder when trying to set things up as an installationpack. Like ISV solutions mostly are. But then again, we only create specific solutions for our customers.

Anonymous said...

I've just started programming .net/MS CRM. After encountering this problem and googeling the error, this page provided an easy and detailed solution. Thank you very much. :)

Anonymous said...

Googled the problem and found your site, what a resource... I'll be coming here again, thank you.

M said...

Very useful, and thanks for posting the error messages verbatim to give google plenty to chew on.

Anonymous said...

The more i learn about reporting services, the more i wish that the people who implemented this would die a slow death!

Ronald Lemmen said...

Anonymous, Reporting services is The current approach is perfectly fine. This problem wouldn't have existed if the CRM team would have included the two dll files in the GAC, but that would have had impact on the performance. So in short, there is nothing wrong with Reporting Services in the situation.

Anonymous said...

Because of http://support.microsoft.com/kb/934690/en-us I prefered deletion of the config entry

Top 5 South Indian Packers said...

Day i will be keep looking for any new updation in this website. Nice article. This blog helped myself in more ways.
Packers movers Trichy
Packers movers Tirupur
Packers movers Salem