ComponentOne WebData for ASP.NET:WebDataObjects for ASP.NET Task-Based Help > Adding References in the Web.Config file

Adding References in the Web.Config file

This topic demonstrates how to add references to WebDataObjects for ASP.NET assemblies in a Web.config file.

If your assembly is in the GAC and not in the bin, ASP.NET will load your assembly at run time only if you include it in a Web.config file.

If you have a control, not just component, in your assembly, and you drop that component on a Web form in your project at design time, Visual Studio generates a reference to the assembly in the .aspx file. For example, adding a C1WebGrid control to a Web form generates the following reference:

<%@ Register Assembly="C1.Web.C1WebGrid.2" Namespace="C1.Web.C1WebGrid" TagPrefix="C1WebGrid" %>

With such reference, ASP.NET will load your assembly from the GAC at run time without problems. Therefore, there is no need for additional references in Web.config if you use a control, not just a component. But if your assembly only has components, not controls, as is the case with C1WebDataObjects, or, if you do not have a control on the Web form at design time, then you need to place those references in Web.config (only if your assembly is NOT in the bin on the development machine). Otherwise, it will not work at run time. It will fail to load the assembly and say that your Component class belongs to an assembly whose reference is not included in the project.

Note: If your assembly is in the GAC and in the bin, it can be loaded twice in Visual Studio at design time.  This can cause problems for objects that have typeconverters. Because of this, ComponentOne requires WebDataObjects for ASP.NET assemblies to be present in the GAC and NOT present in the bin at design time.

Add the following code to Web.config of your WebDataObjects for ASP.NET project, replacing the version number with the correct version number of your assembly:

<configuration>

  <system.web>

 

    <compilation

         defaultLanguage="c#"

         debug="true">

            <assemblies>

                <add assembly="C1.Web.Data.2, Version=2.0.200X3.0, Culture=neutral, PublicKeyToken=545227e12fe8ee01"

    Namespace="C1.Web.Data" TagPrefix="cc1" %>

                <add assembly="C1.Web.Data.Express.2, Version=2.0.20053.0, Culture=neutral, PublicKeyToken=e887d47c090832ef"

    Namespace="C1.Web.Data.Express" TagPrefix="cc2" %>

               

            </assemblies>

    </compilation>

 </system.web>

 

</configuration>

Remove any references to these assemblies from the application once they have been added to the Web.config file.

Note: You will only have to change this code if the assembly version of the .dll changes.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.