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