Hi,

I have a web application that uses a class called "CommonFunctions" located in the App_Code folder.

I can use functions in this class in the ASPX file, e.g.:

<script language="vbscript" runat="server">
dim X as string
X = CommonFunctions.Func1()
</script>

This procedure works correctly in the local host. But when I upload the whole system, it returns the following error:

Compiler Error Message: BC30451: Name 'CommonFunctions' is not declared.

and highlights this line of code:
X = CommonFunctions.Func1()

Any help please

This sounds like a deployment issue. How are you currently deploying the website? You should use the "Publish" option and publish the site. Also be sure to DELETE all *.dll files in your bin\ directory before publishing. Old versions hanging around will cause problems.

Thank you sknake for your reply.

I just upload the localhost root folders to the corresponding root on the web server. I always do this successfully with other projects.
I've tried copying the project to a different local machine and worked correctly.

Is there a further step needed to declare the class for the up-server and not needed locally?

Thanks

Sometimes IIS doesn't recompile assemblies, for some reason it doesn't catch the modification. To solve this restart IIS, or better yet the "World Wide Web Publishing" service.

Start -- Run -- services.msc -- hit <enter>

Locate "World Wide Web Publishing", right click, and restart.

See if that resolves your issue.

I did as you advised, but sadly, it didn't work too.

I solved the problem temporarily by copying the needed class function into the ASPX page and worked correctly. But I still need to have a common function class to work in many pages.

Thanks

Is the "CommonFunctions" class file included in your web project, or is this a separate assembly and you are calling another DLL? If it is another assembly it is added as a reference in your project?

The "CommonFunctions" class is included in the web project as: App_Code\CommonFunctions.vb
The project doesn't use any separate assembly or DLL; just this class.

I take it you are using VS2005 or 2008 if you are using an app_code folder? I suspect you may need to change your publish settings. Also you said web application not website, so just in case, you cannot use app_code in web application projects only web sites, and you need to create the app_code folder by right clicking the project select add ASP.NET folder and choosing app_code from the list.

Anyway, so right click the web application select properties and go to the MSBuildOptions Tab. If you want to be able to change files individually without replacing all the assemblies in the bin folder select "allow this precompiled site to be updatable". If you decide that you want the site to be totally precompiled don't select this checkbox, but remember the asp pages will be just stubs and user controls will be compiled into an assembly. Next I suggest you choose a folder where you want to publish the compiled site too, Visual Studio sets the project folder by default. Once you have done this click apply.

Next you need to right click the web application and click publish, visual studio will then compile the project and publish it to the folder you selected.

At this stage it's probably safer to delete what you have on the web server and replace it with what you have in the new folder. I would also check that your web site is set up correctly in IIS, if this is shared hosting you may need to verify with the ISP that it is set up as an ASP.NET 2.0 site.

Hope this helps, feel free to ask again if it doesn't work out for you!

commented: very detailed +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.