Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Professional ASP.NET 4 in C# and VB by Bill Evjen, Scott Hanselman, Devin Rader; ISBN: 9780470502204
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 27th, 2013, 03:42 AM
Authorized User
Points: 90, Level: 1
Points: 90, Level: 1 Points: 90, Level: 1 Points: 90, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2012
Posts: 19
Thanks: 8
Thanked 0 Times in 0 Posts
Default Chapter1 : CarBuildProvider web.config error

hello

i've made my build provider as you said in section (USING YOUR OWN BUILD PROVIDER) but it has one error : Could not load type 'CarBuildProvider.Car'

thank you.

here is my Codes:
Code:
using System.IO;
using System.Web.Compilation;
using System.CodeDom;
using System.Xml;

/// <summary>
/// Summary description for CarBuilderProvider
/// </summary>
namespace CarBuildProvider
{
  public class Car : BuildProvider
  {
    public override void GenerateCode(AssemblyBuilder myAb)
    {
      XmlDocument carXmlDoc = new XmlDocument();
      using (Stream passedFile = OpenStream())
      {
        carXmlDoc.Load(passedFile);
      }
      XmlNode mainNode = carXmlDoc.SelectSingleNode("/car");
      string selectionMainNode = mainNode.Attributes["name"].Value;

      XmlNode colorNode = carXmlDoc.SelectSingleNode("/car/color");
      string selectioncolorNode = colorNode.InnerText;

      XmlNode doorNode = carXmlDoc.SelectSingleNode("/car/door");
      string selectionDoorNode = doorNode.InnerText;

      XmlNode speedNode = carXmlDoc.SelectSingleNode("/car/speed");
      string selectionSpeedNode = speedNode.InnerText;

      CodeCompileUnit ccu = new CodeCompileUnit();
      CodeNamespace cn = new CodeNamespace();
      CodeMemberProperty cmp1 = new CodeMemberProperty();
      CodeMemberProperty cmp2 = new CodeMemberProperty();
      CodeMemberMethod cmm1 = new CodeMemberMethod();

      cn.Imports.Add(new CodeNamespaceImport("System"));

      cmp1.Name = "Color";
      cmp1.Type = new CodeTypeReference(typeof(string));
      cmp1.Attributes = MemberAttributes.Public;
      cmp1.GetStatements.Add(new CodeSnippetExpression("return \"" + selectioncolorNode + "\""));

      cmp2.Name = "Doors";
      cmp2.Type = new CodeTypeReference(typeof(int));
      cmp2.Attributes = MemberAttributes.Public;
      cmp2.GetStatements.Add(new CodeSnippetExpression("return" + selectionDoorNode));

      cmm1.Name = "Go";
      cmm1.ReturnType = new CodeTypeReference(typeof(int));
      cmm1.Attributes = MemberAttributes.Public;
      cmm1.Statements.Add(new CodeSnippetExpression("return" + selectionSpeedNode));

      CodeTypeDeclaration ctd = new CodeTypeDeclaration(selectionMainNode);
      ctd.Members.Add(cmp1);
      ctd.Members.Add(cmp2);
      ctd.Members.Add(cmm1);

      cn.Types.Add(ctd);
      ccu.Namespaces.Add(cn);

      myAb.AddCodeCompileUnit(this, ccu);
    }

  }
}
web.config Code :
Code:
<configuration>
  <system.web>
    <compilation debug="false">
      <buildProviders>
        <add extension=".car" type="CarBuildProvider.Car"/>
      </buildProviders>
    </compilation>
  </system.web>
</configuration>
and .car code :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<car name="EvjenCar">
  <color>Blue</color>
  <door>4</door>
  <speed>150</speed>
</car>

Last edited by kafshdoozak; January 27th, 2013 at 03:53 AM.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Web.config.. ashokparchuri General .NET 10 April 30th, 2011 05:14 AM
Web.config Error Janhemberg@hotmail.com BOOK: Beginning ASP.NET 4 : in C# and VB 3 August 6th, 2010 03:12 AM
Fix for Web.config Error in ...\Chapter01\LINQforBinding Web Sites rogerj BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 0 February 18th, 2009 12:59 PM
web.config error koco ASP.NET 2.0 Basics 1 February 16th, 2007 11:04 AM
Web.config error ashokparchuri General .NET 4 June 28th, 2005 04:51 AM



All times are GMT -4. The time now is 10:06 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.