Wednesday, July 12, 2006

As part of DotNetDoc's new "Ask the Doc" format, we are starting our journey by taking a page from the Zen Master himself Scott Hanselman. We will be walking through his list of questions posted in his, "What Great .NET Developers Ought To Know" post. We will not only try to answer the questions but give each a "deep dive" so that we not only can answer the question, but so that we UNDERSTAND the answer. We will go one question at a time until we reach the end. I hope you enjoy, and thanks Scott for the thought provoking questions.

.Net Ought To Know #6 : Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family?

The answer to the question is not that tough so I thought we would go a little deeper and talk about Components, Controls, and Containers Oh My!! (Sorry I couldn't resist). In the .Net Framework, simply put, a component is a class that implements the System.ComponentModel.IComponent interface or derives from a class that does. A component is something that can be reused. C# is considered a component-oriented language. Re-use is everything in component-oriented design. Putting together pre-tested parts is faster and cheaper then coding it yourself. So to summertime, a component is any class that directly or indirectly implements the IComponent Interface. A component can be added to the toolbox and dragged and dropped onto a form.

A control on the other hand is a component that provides a UI. To do this you need to implement System.Windows.Forms.Control OR System.Web.UI.Control. So a control is basically a component that has visual properties.

This finally leads us to the answer to this question. You need a place to hold your components and controls. This is done in a Container. A Container is a class that implements the System.ComponentModel.IContainer interface (directly or indirectly). Since this container holds your controls, it is easy to access the controls dynamically.

    9 Private Class ControlWalker

   10     Private mContainer As Object

   11     Public Sub New(ByVal Container As Object)

   12         Dim cControl As Control

   13         If Container.haschildren Then

   14             For Each cControl In Container.controls

   15                 'add this control to the controls collection

   16                 m_controls.Add(cControl)

   17                 If cControl.HasChildren Then

   18                     'This control has children, create another

   19                     'ControlWalk go visit each of them

   20                     Dim cWalker As New ControlWalker(cControl)

   21                 End If

   22             Next cControl

   23         End If

   24     End Sub

   25 End Class

So you tell me now, this should be easy. What are 3 containers in then Windows Server Family?

Happy Programming.

Doc

posted on Wednesday, July 12, 2006 12:17:16 PM (GMT Daylight Time, UTC+01:00)  #    Comments [3] Trackback
Monday, July 10, 2006

As part of DotNetDoc's new "Ask the Doc" format, we are starting our journey by taking a page from the Zen Master himself Scott Hanselman. We will be walking through his list of questions posted in his, "What Great .NET Developers Ought To Know" post. We will not only try to answer the questions but give each a "deep dive" so that we not only can answer the question, but so that we UNDERSTAND the answer. We will go one question at a time until we reach the end. I hope you enjoy, and thanks Scott for the thought provoking questions.

.Net Ought To Know #5 : What is strong-typing versus weak-typing? Which is preferred? Why?

In strongly-typed programming languages you usually have to declare variables prior to using them. Strong-typing is the strict enforcement of [type] rules. All types (int, short, long, string) are know at compile time and are statically bound. So C# is a strongly-typed language because variables must be assigned a type before you use them. If you came from the ASP world then you will remember having to use either Javascript or VBScript. Variables that you declare in either of those languages can hold any data type which makes it weakly-typed.

But lets take this up a level. Instead to talking about programming languages, lets talk about strongly-typed/weakly-typed objects. The DataSet object is a great example. If we use a weakly-typed dataset, the developer needs to know the name of the table and the name of the field being requested. Since we are just passing strings, this code will compile and will not show any possible problems (like typing the name of the table wrong) until run time.

  string s = (string) myDataSet.Tables["Customers"].Rows[0]["CustomerID"];

If our Dataset is Strongly-Typed, we are able to access the names of the tables and columns directly. Any errors are caught at compile time.

  string s = myDataSet.Customers[0].CustomerID;

I am not really going to argue which is better, I will leave that up to you. I will leave you with this question though; would you rather catch your errors at compile time, or run-time?

Happy Programming.

Doc

posted on Monday, July 10, 2006 9:24:56 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
Sunday, July 09, 2006

Setting up membership for your ASP.Net website is pretty simple. All you need to do is:

  1.  run the scripts using the aspnet_regsql.ext tool (C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727\aspnet_regsql.exe    your version number may be diferent) to set up the database tables.
  2. Add a membership section to your web.config. Making sure that you add the <clear/> tag since you need to override the machine.config.

       41     <membership>

       42       <providers>

       43         <clear/>

       44         <add name="AspNetSqlMembershipProvider"

       45                   type="System.Web.Security.SqlMembershipProvider,
                             System.Web, Version=2.0.0.0, Culture=neutral,
                             PublicKeyToken=b03f5f7f11d50a3a
    "

       46                   connectionStringName="LocalSqlServer"

       47                   enablePasswordRetrieval="false"

       48                   enablePasswordReset="true"

       49                   requiresQuestionAndAnswer="true"

       50                   applicationName="/"

       51                   requiresUniqueEmail="false"

       52                   minRequiredPasswordLength="1"

       53                   minRequiredNonalphanumericCharacters="0"

       54                   passwordFormat="Hashed"

       55                   maxInvalidPasswordAttempts="5"

       56                   passwordAttemptWindow="10"

       57                   passwordStrengthRegularExpression="" />

       58       </providers>

       59     </membership>

       60   </system.web>

  3. Add a connection string once again using the <clear/>  tag to clear out the machine.config settings. (I will tell you why soon) 

       16   <connectionStrings>

       17     <clear/>

       18     <add name="LocalSqlServer" connectionString="Data
                 Source=xxx;Initial Catalog=xxx;Persist Security
                 Info=True;User ID=xxxx; password=xxx
    " />

       19   </connectionStrings>


  4. Then load up the Web Site Administration Tool by going to Website\Asp.Net Configuration in VS2005.

  5. You will then be about to configure your membership using SQL2000/2005 using this tool.

So where is the gotcha you might ask?  Well, if you try to name your connection string anything other than LocalSqlServer, when you get to the provider tab you will see a message that says "No Provider Created".  This is why you need to clear out the connection string section using the  <clear/> tag so that you can override the setting in the machine.config.  

 

I hope that helps someone.

Happy Programming

 

Doc


posted on Sunday, July 09, 2006 11:10:27 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
Friday, July 07, 2006

I was just talking to a possible client the other day when the inevitable subject of "Which Technology is the Best" came up. He was a designer but also did a little bit of PHP. The reason he used PHP was because that was what his other Designer friends used.  This of course started up the "Which is better" argument/discussion.

I have always firmly held the stance that :  I JUST DONT CARE. 

C# or VB.Net, which is better?   Who cares?  What is the client paying for? I program in both, and you should too.

ASP/ASP.Net or PHP?  Who Cares,  how many jobs can I get doing PHP sites and how many with ASP/ASP.Net. ( You may have noticed that I did not even go into the enormous difference between PHP and ASP.Net)

The bottom line is, go where you can find work AND do it well!!!  Whatever you do.  

On that note, I found a great blog post that talks about this HERE.  Check it out.

Happy Programming!

DotNetDoc

posted on Saturday, July 08, 2006 1:56:32 AM (GMT Daylight Time, UTC+01:00)  #    Comments [3] Trackback

OK... So one of the blogs I read is from a very technical person who writes a very non-technical blog. Most of the .Net world already knows who his is but if you have been living on another planet, his name is Rory Blyth.

Now his blog can get a little over the top for me sometimes but it is usually hysterically funny.  So I was going through some emails recently and I came across a couple of his posts that I had emailed to someone. The cracked me up all over again.

So I thought I would share them:

The first one is about his experience with T-Mobile and their phone system. Maybe you need to be a customer to find this funny but ..... well maybe not.

http://neopoleon.com/blog/posts/14880.aspx

The second one is more of a cartoon then a blog post. If you have ever worked in a corporate environment, you will definitely get a kick out of this. On the other hand, if you say "I don't get it", then you are management material all the way!!

 http://www.neopoleon.com/blog/posts/434.aspx

Enjoy

DotNetDoc

 

 

posted on Saturday, July 08, 2006 12:08:18 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
Thursday, July 06, 2006

As part of DotNetDoc's new "Ask the Doc" format, we are starting our journey by taking a page from the Zen Master himself Scott Hanselman. We will be walking through his list of questions posted in his, "What Great .NET Developers Ought To Know" post. We will not only try to answer the questions but give each a "deep dive" so that we not only can answer the question, but so that we UNDERSTAND the answer. We will go one question at a time until we reach the end. I hope you enjoy, and thanks Scott for the thought provoking questions.

.Net Ought To Know #4 : What is the difference between an EXE and a DLL?

The main difference between an EXE and a DLL is the fact that an EXE contains instructions for the processor and has an entry point for the execution to start. In this .Net Drag and Drop world where most of the underlying tasks are taken care of for us, this is sometimes hard to see. In the classes I teach, in order to focus on the the code and not the bells and whistles, I often assign Console Applications for homework. The entry point for a console application is the Sub Main() procedure. You can see this by going to project properties and looking at the Startup object. Since a console application will create an EXE, it needs to know where to start execution.

 

 

If we change the Application type from Console Application to Class Library, you will notice that the Startup object type now says <none>. This is because a DLL cannot be executed(or loaded)directly, it can only be called by another process.

 


It is also interesting to note how this question relates to .Net Ought To Know #3. An EXE runs in its own address space(out-of-process) while a DLL will run in the address space of its host (in-process). If you wanted to dive deeper into this, you could load up both a DLL and EXE in ILDasm.exe and look for the <entrypoint> marker in the EXE file.

Happy Programing.

Doc

posted on Thursday, July 06, 2006 4:44:18 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
Monday, July 03, 2006

As part of DotNetDoc's new "Ask the Doc" format, we are starting our journey by taking a page from the Zen Master himself Scott Hanselman. We will be walking through his list of questions posted in his, "What Great .NET Developers Ought To Know" post. We will not only try to answer the questions but give each a "deep dive" so that we not only can answer the question, but so that we UNDERSTAND the answer. We will go one question at a time until we reach the end. I hope you enjoy, and thanks Scott for the thought provoking questions.

.Net Ought To Know #3 : What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?

Well since most people are still not using a 64 bit operating system, we are going to keep this discussion limited to a 32bit OS. In the NT Flavor of operating systems, 4GB of memory is available to each process but it is split 50/50 with with the operating system.

So each process has 2GB of memory available for its private use. The other 2GB is used by the operating system, devices, graphics cards, etc.. Keep in mind, the 4GB/2GB size is regardless of how much RAM you have installed.

This would affect system design if you are creating an application that uses very large data structures or applications like mail servers, database management servers etc.. To address the need for more memory space, you can use a /3GB switch which then splits the memory usage from 50/50 to 75/25. Allowing your application to use 3GB of the 4GB available.

Happy Programming

Doc

posted on Tuesday, July 04, 2006 1:17:21 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
Friday, June 02, 2006

Just an FYI.. I will be apprearing at UCLA on Saturday as part of their Masters Series.  If you are interested, you can check here.

http://ladotnet.org/

DotNetDoc

posted on Friday, June 02, 2006 7:14:30 AM (GMT Daylight Time, UTC+01:00)  #    Comments [2] Trackback
Saturday, May 27, 2006

SQL PROMPT - From Red Gate Software

While I was reading some blogs today I came accross THIS from Scott Mitchell.   SQL Prompt from Red Gate software. It gives you IntelliSense for SQL. Pretty cool stuff. The best part is that it is FREE. Check it out HERE.

Doc

posted on Saturday, May 27, 2006 9:20:01 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback