Solved

understanding asp.net code behind

Posted on 2006-06-13
3
403 Views
Last Modified: 2013-11-25
Hi

I want to clarify my understanding of asp.net code behind. I am going to write down my understanding. I would appreciate it if you could correct bits or add on bits I am missing.

Code behind doesnt mean anything to the asp.net engine. It is something specific to Visual Studio. It tells VS where the code behind for a web page is.

When you make solution in VS all of the vb files are compiled into a dll and put in the application bin directory.
When you put this on the website, the asp.net engine looks for all classes it needs in the dlls in the bin directory
Will it look in all the dlls in the bin directory?
Does it look anywhere else?

When you have a dll you dont need to upload the vb files. In fact, when you have a dll you shouldnt upload the vb files because they take precedence and the asp.net engine will compile the vb files every time the application starts and ignore the dll

If you upload the vb files and not a dll, the asp.net engine will compile the vb files dynamically into a dll every time it runs the application.

However, I DONT UNDERSTAND THIS:
I was experimenting with my website and I deleted the dll. If what I have said is correct, asp.net should have compiled all the vb files into a dll and the application should have run ok. However, it didnt and I got a could not load type message. Why is this????

You can use the code behind model without visual studio. YOu can give asp pages a src attribute which tells asp.net where to look for the class file

If you use a src attribute, does the asp.net engine compile the vb files into a dll? I dont think it does. I believe if you want to compile the files you need to use the vbc compiler.


Any comments to add to  my understanding are welcomed

thanks
andrea
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 300 total points
ID: 16895017
>> Will it look in all the dlls in the bin directory?
Yes.

>> Does it look anywhere else?
It will look in the GAC if it doesn't find it in /bin. It may look in other paths that you specify in your config (at least, it will with .Net 2.0).

>> If you upload the vb files and not a dll, the asp.net engine will compile the vb files dynamically into a dll every time it runs the application
You shouldn't upload the .vb files. The ASP.Net engine will compile the IL code stored in the DLL using the JIT compiler the first time it is run. The DLL has to be present on the server, the ASP.Net engine will not compile your .vb files.

>> You can use the code behind model without visual studio. YOu can give asp pages a src attribute which tells asp.net where to look for the class file
True. But trying to do it freehand is more trouble than its worth.
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 200 total points
ID: 16895038
Here's an MSDN article from Fritz Onion (who knows what he's talking about):

http://msdn.microsoft.com/msdnmag/issues/06/01/ExtremeASPNET/

To answer your specific question:

Unless you're using the SRC attribute, ASP.NET will need to compiled DLLs to acquire the type that the page inherits from (even if the source code is there).  If you use the SRC attribute, it will compile the source on-the-fly (NOT into a static DLL) and load the types from the assembly in memory.  There may be some caching involved so that it doesn't re-compile unless there's a change in the source code, but I don't have first-hand knowledge of that.
0
 
LVL 25

Expert Comment

by:dstanley9
ID: 16895043
Sorry, that should be:

ASP.NET will need THE compiled DLLs to aqcuire...
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question