Saturday, December 25, 2010

Code behind file not found

"If your code behind files are not compiling to dll then the problem could be codefile attribute, replace it with codebehind"
 
Hi All,

A few days back while working on a DNN module which is actually an extension to DNN core module Survey I faced a problem.

As this module's code comes in WSP version I copied C Sharp version of its code in DNN module template type visual studio project and then compiled it so as to get a DLL of its code. It got built after a few arrangements(like commenting a few lines :)

Then I copied the DLL to bin folder and tried to create module as per the procedure. It worked good all the way around till module creation. Then I added this newly created module to a page and BANG!!, here comes the error.

Error said,
type survey.ascx.cs not found

Note: survey.ascx is the view control of my module.

From the error message and placing code behind files in module folder I figured out that my module was able to get code in files like provider model classes and controller and info classes. It was just not getting the code-behind files of the ASCX controls used although it was able to pick codebehind code if if I place the code behind files in module's folder itself.

Thus problem became clear that something was stopping code behind files from compiling. So I compared my survey.ascx file with an old module's viewcontrol.ascx file and in the first line I got the culprit.

It was "codefile" attribute in ascx file's code directive line. I replaced it with codebehind and the problem was resolved.

So the moral of story is
if your code behind files are not compiling to dll then the problem could be codefile attribute, replace it with codebehind and enjoy!!!!!

Friday, December 24, 2010

Drop failed for database. Currently in use. Error 3702

Hi All,

Yesterday while working on DNN I needed to restore my website to a previous state. So I thought to drop my current working database and restore a backup copy.

I use MSSQL SERVER 2005. While dropping my working database I got error as below

Drop failed for database {database name}

cannot drop database because it is currently in use. Error 3702



To resolve this problem I googled a bit and then found below as a solution. This worked as a magic to my problem.

USE Master;
GO

ALTER DATABASE {database name} SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

DROP DATABASE {database name};
GO



Hope it helps you guys also.

About Me

My photo
Delhi, India
Fun, music, travel and nature loving, always smiling, computer addict!!