hyp3rg3om3tric
hyp3rg3om3tric

Reputation: 549

ASP.NET 3.5 cannot see my code behinds

I am developing a piece of an existing web site and am having numerous issues trying to upload my files to the server. Everything runs fine locally, but once I put my files on the server things start breaking.

Right now I have a page that gets this error

"Parser Error Message: Could not load type '[Namespace].[PageName]'

. If I take out the inherits statement, it works. The namespace and the pagename are declared in the code behind, which is referenced in the page header.

I also just noticed that all of the pages that predate me don't have code behinds.

Upvotes: 1

Views: 124

Answers (4)

hyp3rg3om3tric
hyp3rg3om3tric

Reputation: 549

So I eventually talked to the lead developer for the other group that works on the site. He explained that they do a Solution Rebuild then just move any changed as*x files and the /bin .dll. For some reason, my subversion client didn't actually update anything when I asked it to update, so my branch didn't have some new controls the other group made. When I would build my solution it didn't include the .dlls for the new controls, so when I uploaded my dll the new controls weren't defined and I got the same message. When I took the new dll down, my controls weren't defined.

Anyway, I fixed that. Thanks for the answers.

Upvotes: 0

bsmith95610
bsmith95610

Reputation: 73

Test easiest way to get your code up and running would be publishing the code. Inside of your project in Visual Studio right click on your application and click on publish then for the location you can just create a folder on your local system and select only files needed to run this application then select publish. It will only copy the files needed to run the application and you can copy those files to your server and everything should be correct. I will also copy your web.config/app.config file so make sure that everything is correct in that file or delete that file from the directory once the publish is done.

Upvotes: 1

David
David

Reputation: 73564

There are two options for putting a file on a web server.

  • One option is to compile it and use a "Publish" feature, in which all of your code-behind files are NOT on the server, and are instead are compiled down to the .dll.
  • Another is to not compile the site, and simply copy all the aspx ans .cs (or .vb) files out there, uncompiled.

Actually there are three, but I think you only need to deal with these two right now. They are described further at http://msdn.microsoft.com/en-us/library/ms178466(v=vs.100).aspx under the "Flexible Deployment" section.

Your predecessor apparently used the first method. The only way to fix this is to get the compiled .dll files out of the \bin directory, and decompile them using a tool like Reflector or Teleriks's Just Decompile. (The latter is free, the former has a free for a limited time trial period.)

Alternatively, if you can get the full source code, you can simply remove all the content already out ther and publish it using the non-compiled method. Of course, there will be down time, and you'll need to test pretty carefully...

Upvotes: 2

Joe Enos
Joe Enos

Reputation: 40393

When you have a codebehind file, it needs to get compiled into a DLL, and that DLL needs to be in the bin directory of the webserver. It doesn't actually work fine without the Inherits - nothing from your codebehind would be in there - it may only display ok initially, but none of the events would fire.

If the rest of the site is all done with the code included in the .aspx pages, then those pages are all standalone. But if you want to use codebehinds, then you'll need to publish the DLL.

Upvotes: 1

Related Questions