Thursday, April 19, 2012

error BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types. [ASP.Net]

One day in my coding life as a consultant I met this error message: "~\file.vb(250): error BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types."

If you are compiling an ASP.Net Web Site (Attention: It's not a Web Application,) using the so called command prompt mode:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler -p "C:\WebsiteSourceFolder" -v / C:\WebSiteDestinationFolder

You may found this particular error message.  Thus nothing was generated in the C:\WebSiteDestinationFolder.  Eventhough if you may be able to access the virtual directorized C:\WebsiteSourceFolder through the web browser.

[What Really Happened]
What really happen is I made a copy of file.vb named "copy of file.vb" in side the C:\WebsiteSourceFolder as a backup copy.  I'm trying to keep the original file intact.  What really happened is the compiler found a duplicate class file.  Thus generating the error code.

[Solution]
Take out / remove the backup copy / duplicate file from the Source Folder that you want to compile.  You may want to find a file with the same class name your case isn't creating copies of the offending source code.  Then you will be able to compile the ASP.Net Web Site.



2 comments:

  1. Just Go to your onclick button. then again click that button , it shows code behind page ... Thats it Problem Solved..:-)

    ReplyDelete