954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem when calling class online

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

Datsun90
Newbie Poster
22 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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

Datsun90
Newbie Poster
22 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

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

See if that resolves your issue.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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

Datsun90
Newbie Poster
22 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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?

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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.

Datsun90
Newbie Poster
22 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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!

sedgey
Junior Poster
131 posts since Jan 2007
Reputation Points: 68
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: