Tuesday, August 19, 2008

Call a method in an aspx page it runs perfectly fine on development machine when deploy it on the production server it throws an error BC30451

I would like to share some of my experience with code. First post is here.

call a method in an aspx page it runs perfectly fine on development machine when i deploy it on the production server it throws an error BC30451 type not declared



Last week I had a strange experience. I am using Visual Web Developer for creating web applications. I was working for one of our clients. I added some new functionalities to web application and put those methods in a class file of App_Code folder. Methods were declared as public and create new instance of that classes in aspx pages. So I could access those methods from my aspx pages. It worked perfectly form my local development machine. But when I tried to deploy it on the production server it throws some error "BC30451 type not declared" at the point where I created the instances of the classes.
I tried every possible methods to figure out the exact cause of the problem. First i put the class inside a namespace because it was not like that. But it made any change in the error

Finally I got the solution.
My web application on the production server resides inside a subfolder of "httpdocs" and the default App_data folder and everything in the root of "httpdocs". I had created the App_Code folder inside that subfolder and copied the class files there.
To rectify that problem I simply create App_code folder in the root of "httpdocs" and copied class files to there. Now it is working without fail.

I think the IIS looking class files for the root of the folder which created as an application. In this case "httpdocs" was the created application folder so IIS will always look there for class files, if it is not there will thrown as error message.

No comments: