p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional ASP.NET 3.5 SP1 Edition: In C# and VB (http://p2p.wrox.com/forumdisplay.php?f=497)
-   -   Problems with BuildProvider code (chapter 1) (http://p2p.wrox.com/showthread.php?t=76062)

DevonTaig September 4th, 2009 10:08 PM

Problems with BuildProvider code (chapter 1)
I'm getting an error, "Could not load type CarBuilderProvider.Car" when I attempt to compile the code in chapter 1. The .car file I have is below:

<?xml version="1.0" encoding="utf-8" ?>
<car name="SamsCar" >

And the XML snippet from the web.config file is below:

<add extension=".car" type="CarBuilderProvider.Car" />

I didn't modify the buildProvider code from the solutions at all.

Any ideas?

Imar September 5th, 2009 06:31 AM

Hi there,

Looks like you maybe missing a reference to the DLL containing your build provider? Maybe this helps:




DevonTaig September 5th, 2009 09:00 PM

Thanks - Got it working
The trick here is to create a separate project and compile the BuildProvider as a .net .dll. Then in the ASP.NET website, that buildprovider .dll must be added as a reference...It seems that when you do that, it ends up going into the /bin folder (which I had added manually to the ASP.NET website).

There's not a description of those steps in the book...from the text it sounds like you would have the carbuildprovider.cs class in the app_code folder, but that will not work. The only thing related to the build provider in the app_code folder is the XML snippet that defines the car. You have to compile it and have it in the /bin folder. The screen shot (image 1-15 is helpful to look at, but in some ways it muddies the water by showing an app_data folder which I don't think is needed at all).


Imar September 6th, 2009 06:59 AM

Hi DevonTaig,

I don't have the book so I don't know what the original instructions were, but I just created a quick test site with just the App_Code folder and it worked fine. Here's what I did:

1. Create a class that inherits BuildProvider in its own namespace in App_Code

2. Created an override for GenerateCode in that class

3. Added the provider to the web.config like this:

<add extension=".sample" type="MyNamespace.MyClassname" />

4. Created a .sample file

5. Fired up a second instance of Visual Studio and debugged the first one with the web site and the build provider.

6. As soon as I start running the site with the build provider, my breakpoint in GenerateCode gets hit.

So, it seems to work fine when using App_Code.

Are you using a Web Site Project or a Web Application Project? App_Code is not used in WAPs....



jsymons October 14th, 2009 01:59 PM

DevonTaig & Imar,

I'm stumped on this one as well. I've added a reference to the compiled CarBuildProvider.dll which adds it to the Bin folder as was stated here and not in the book, yet I don't get Intellisense for the properties and method even though the class name itself can be accessed via Intellisense. All I see in Intellisense is Equals and ReferenceEquals.

Additionally, I also learned that if you have to recompile the CarBuildProvider.dll for whatever reason, your Website won't get a fresh copy of it. In order to get a new copy you have to right-click on the CarBuilderProvider.dll file within the Bin folder and select "Update Reference".

Any help would be greatly appreciated.



jsymons October 14th, 2009 02:11 PM


Posted to soon. I found the mistake. I previously had:


dim myCar as New Eclipse
' Got Equals and ReferenceEquals in Intellisense after typing the period here
Label1.Text = Eclipse.

When it should have been this (Note: The Intellisence worked as expected here):

dim myCar as New Eclipse
Label1.Text = myCar.Color



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

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