Link to home
Start Free TrialLog in
Avatar of quest_capital
quest_capital

asked on

Trying to implement new code thats in an App_Code directory but I get a precompiled error.

I'm trying to implement new code thats in an App_Code directory but I get the error:
The directory '/wwwroot/App_Code/' is not allowed because the application is precompiled

How can I add this code to my existing web site without error?

I'm using:
Microsoft Visual Studio 2005 c#
Avatar of NunoGodinho
NunoGodinho

Hi,

   This happens because the App_Code folder is used when you don't compile your application, and so it will be possible for you to include more code on the App Code folder because the application is being parsed, and not precompiled. But in this case your application is using precompilation and for these reason is using an assembly that will exist in the bin folder of the application, and so in order to change this you'll need to open the project again in the visual studio and placed in the project in another folder other then the App_Code.

Hope it helpes,

  Nuno Godinho
Avatar of quest_capital

ASKER

NunoGodinho

The folder that my web site is in is in the wwwroot folder so do I move the Image.cs to the root?
How is it referenced or do I move the code in anther page?

The Image.cs (and the other files that are download) is here:
http://www.developerfusion.co.uk/show/4688/

I have to rename the default.aspx & default.aspx.cs to something else (because they are used) and modify the web config to add:
<appSettings>
<add key="imageDir" value="images"></add>
</appSettings>

<httpHandlers>
<add verb="GET" path="Image.ashx" type="Thumb.ImageHandler"></add>
</httpHandlers>

I am a total newbie to this HELP................................
Hi,

  All that you have done until now is right, but the only thing is that you have to insert your image.cs in your ASP.NET Project that is installed on your wwwroot, and to do so you should make the following steps:

    1. Open the Web Site Application by opening the csproj file in your Visual Studio 2005
    2. Select the View All files
    3. Select the Image.cs file and with a right-click mouse button select the option "Include in Project"
    4. Then Compile your Web Application and then place it on the wwwroot again (this step is only needed if the project is not already on the wwwroot)
    5. Run the Web Application

  Now your done.

     Nuno Godinho
NunoGodinho

The image.cs is in the root a seem to be included in the project but now the Web.config has an error that the
Image.ashx is not in the there... (it was never in the zip file to begin with)
<add verb="GET" path="Image.ashx" type="Thumb.ImageHandler">

Is this a ghost file are what?
But the wierd thing is that the if the project is ran in a separate folder it will work.
Avatar of Bob Learned
If you are precompiling your pages, then don't copy anything from the App_Code folder, since that is the area where the dynamically compiled pages live.

For us, we can live with the uncompiled, first person in, and all that, so we don't precompile our pages.

Bob
TheLearnedOne

When I started this web site I had one idea that the site was going to be precompiled.
Is there a setting to run the site uncompiled.
SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TheLearnedOne

How do I change to Uncompiled?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Nuno Godinho
This is odd:
The "No Build" was already selected and the "Build Solution action" was already uncheck
Also in the MSBuild Option section the check box is check to Allow this precompiled to be updateable

Does your problem happens after the publishing of the website? If so try to delete the App_Code folder and try again.
All you need to do is to copy the files to the web site, as is, with the .aspx pages and the .vb/.cs source code, and they will be compiled at the first access.

Bob
Error from web.config
Parser Error Message: Could not load type 'Thumb.ImageHandler'.

<add verb="GET" path="Image.ashx" type="Thumb.ImageHandler"></add>

Again just for refrence
there is no Image.ashx file and the image.cs is in the wwwroot/ not in a App_Code folder
Hi,

   You have to place the file that has the "Thumb.ImageHandler" class on the App_Code folder, if not he will try to find it on the compiled files that exist on the bin directory.

   So it should be like this:

       - Image.cs should be placed on the wwwroot/App_Code folder
       - <add verb="GET" path="Image.ashx" type="Thumb.ImageHandler"></add> should be placed on the Web.Config

    Then the next time you make a request for a page on the application, the ASP.NET will compile all the code that exists on the App_Code folder and then you can use it.

This should solve your problem,

   Nuno Godinho
Nuno Godinho

I'm back to the same problem
The directory '/wwwroot/App_Code/' is not allowed because the application is precompiled.
I had to delete the PrecompiledApp.config and no more error.