Tuesday, March 13, 2007

So I am at the keynote for the MVP Summit and Bill (Yea, we are on a first name basis) just finished his "speech". We are now in the Q&A phase. It has been quite interesting. There have been some great questions on where Microsoft is going in the future, what he thinks is going to really take off but has not yet (tablet, voice recognition) .

One of the best questions was from someone who had started on the Alistair. He read the back panel that instructed users that needed help to Call Bill or Steve… What a crack-up. He got Bill to sign it for him ;)

Well off to another session… more soon.

Doc

posted on Tuesday, March 13, 2007 10:32:50 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
Sunday, March 11, 2007

I received a question for a blog reader the other day complaining that they could not find the <machineKey> element in their Machine level web.config or their machine.config file. It was quite puzzling to them and thought that someone may have removed it.

Well, they were right and wrong. Someone did remove it, but that someone was Microsoft.

When .Net 2.0 came out, they did some "reconfiguring" of the config files. The first thing you will notice is that they moved most of the items that developers may want to change to a "Machine-Level" web.config file which can be found right alongside the machine.config file in the C:\WINDOWS\Microsoft.NET\Framework\v2.x\CONFIG folder. The second thing they did was remove elements from the machine.config file that were set at their default level. So if you don't want to change the machineKey, it will be set like the following.

You can find these settings in the web.config.comments file in the same directory.

You can of course override the defaults by adding the element to the machine.config, machine-level web.config, or a web.config in your application.

Happy programming

Doc

posted on Monday, March 12, 2007 3:24:53 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
Monday, February 26, 2007

What it Code Access Security (CAS)? And why is it important to me?

Well, the simplest definition can be found in the name itself, what resources are you code allowed to access (Code Access Security). Will your code be allowed to access local files? The registry? SQL Server? These are questions that you should be asking yourself when you are designing your application but far too often, security is just an afterthought it the design process.

CAS is also sometimes called evidence-based security. To determine the access your code possesses, the Common Language Runtime (CLR) evidence it gathers about assemblies. This "evidence" is determined by a number of factors.

  • Where did the code come from?
    • The site, URL, Zone, and Application Directory.
  • What does the assembly contain?
    • Evidence Hash (Not the Strong Name Hash)

    The Hash evidence is simply a compact identifier that uniquely identifies a particular compilation of a component. The Hash evidence is added by the assembly loader to all assemblies and allows security policy to recognize particular builds of an assembly, even when the assembly version numbers have not changed.

    A hash value represents a unique value that corresponds to a particular set of bytes. Rather than referring to an assembly by name, version, or other designation, a hash value designates the assembly without ambiguity. Names are subject to collisions in rare cases where the same name is given to completely different code. Different variations of code can accidentally be marked with the same version. However, even changing a single bit results in a very different hash value.

    Hash values are a cryptographically secure way to refer to specific assemblies in policy without the use of digital signatures. A secure hash algorithm is designed so that it is computationally infeasible to construct a different assembly with the identical hash value by either an accidental or malicious attempt. By default, evidence from the SHA1 and MD5 hash algorithms is supported, although any hash algorithm can be used through GenerateHash.

  • Who wrote the code :
    • Is the assembly Strongly Named? If so, what is the Strong Name?
    • Who is the publisher of the assembly? Is it digitally signed?

 

Evidence is where CAS starts. It is the who, what, where and why of your code. Let's talk about the about the different types of evidence.

The assembly loader works with the first four parts of the evidence, the Site, URL, ZONE, and Application directory. All four of these are derived by the CODEBASE URL. The URL evidence is the simplest since it is just be the URI of the assembly. The site evidence is derived from the URL. If the URL of the assembly is http://www.DotNetDoc.com/downloads/samplestuff.dll then the Site evidence will be www.DotNetDoc.com. But if the assembly is file based (C:\MyStuff\AndThings\samplestuff.dll) then this evidence will be blank. The Zone evidence also comes from the URL but is divided into five possible Zones :

  • My Computer – All code loaded from local file system
  • Intranet – All code loaded off of a remote file system using mapped drives
  • Trusted – IE Mapped Trusted Sites
  • Internet – All code loaded off the internet
  • Not Trusted – IE Mapped Not Trusted Sites

The final location-based evidence is ApplicationDirectory. This evidence specifies the base directory for running the application. This is usually used to grant special permissions to assemblies that are run from the same location as the base application.

    

      

 

posted on Monday, February 26, 2007 7:55:51 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
Sunday, February 25, 2007

I hate to steal a blog post but Scott Hanselman always finds the coolest tools.
http://www.hanselman.com/blog/BinaryFortressSoftwaresASPNETViewStateHelperATreasureTroveOfTools.aspx

 

This time it is binary fortress. It is a tool for viewing View State. It is easy to use and to the point.

Thanks for pointing it out Scott.

Doc

posted on Monday, February 26, 2007 12:03:21 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback

Well, I finally did it, I set up my office 2007 to allow me to blog from word. It is pretty Cool.

It allows me to easily cross stuff things words out. Color how I want. Add pictures with cut and paste. Using Snag-it.

UPDATE : Can't seem to publish pictures yet….hmmmmm… I wonder why

UPDATE 2: User Error… I did not format my FTP String Correctly

And format them however I want.

I can select specific categories but the best thing is the fact that I get SPELL CHECK!!! I really need this ;)

Pretty cool stuff…. I use das Blog so I upgraded to the 1.9 version and used this tutorial to get it done.

http://www.colinneller.com/blog/SyndicationService.asmx/GetRssCategory?categoryName=Office

Happy Programming

Doc

posted on Sunday, February 25, 2007 6:06:19 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] Trackback
Thursday, February 22, 2007

I have had a heck of a problem with Adobe on my system and it was driving me crazy. It would work as a stand-alone program, but whenever I tried to open up a PDF file through IE, it would lock up first IE and then Regular Explorer.  So you would think I could just uninstall and re-install right???

Well you would be wrong. First, when I tried to uninstall, it told me that I was missing a patch file and would have to abort......Great....just what I wanted....

So I found this tool from MS that allows you to remove items that were installed using Windows Installer

http://support.microsoft.com/default.aspx?kbid=290301

It seems pretty straight forward, Click on the program and select Remove.

That went pretty smooth. But then when trying to re-install Adobe Acrobat version 8 (The current version), I could not get the Adobe downloader to work.

What a pain !!!!!!!!!!!

Well, to make a long story short.... I am sure there is a work-around to this.... but I instead found a stand-alone installer at this link.

http://ardownload.adobe.com/pub/adobe/reader/win/7x/7.0.8/enu/AdbeRdr708_en_US.exe

It is only 7.0.8, but at least my system doesnt crash now :).   Maybe when I have time I will troubleshoot this more.

Happy (or not so happy) programing.

Doc

posted on Thursday, February 22, 2007 11:38:39 PM (GMT Standard Time, UTC+00:00)  #    Comments [1] Trackback
Saturday, August 19, 2006

So I have mentioned before that LADotNet.org runs a Masters Series on Saturdays and this Saturday is no different. This week it is being presented by Ken Getz. Ken is a great presenter and we are glad to have him back in California (Sorry Florida). Anyway, as he was going through delegates and events and he covered something I was not aware of.

Anonymous Delegates. Whenever I used delegates in the past, I aways had a method that could be passed that would handle the call. You can also pass a proceedure or "Block of Code" instead of passing a pointer to a method like below. (Both C# and VB)

  184     static void AnonymousDelegate()

  185     {

  186       FileSearch4 fs =

  187         new FileSearch4("C:\\", FILESPEC, false);

  188       fs.Handler =

  189         delegate(FileInfo file)

  190         {

  191           Console.WriteLine("{0} ({1})",

  192             file.FullName, file.Attributes);

  193         };

  194       fs.Execute();

  195     }

 

I am not sure of a real use for this but it was interesting to see someting new.

 

Doc

posted on Saturday, August 19, 2006 10:12:53 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
Friday, July 14, 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 #7 : What is a PID? How is it useful when troubleshooting a system?

If you have ever used the task manager (right-click on start bar and select Task Manager) and gone to the Process tab, then you have seen the processes that are running on your system. The default set-up of the task manager does not show the PID or Process ID. To add this, go to View/Add Columns on the menu and check the box next to PID(Process Identifer).

The PID is an integer that is assigned to each process in your operating system.It is usefull when you need to diagnose problems with your application since it allows you to uniquely identify each process.

 

In the .Net framework, you can access this information by using the System.Diagnostics namespace.

   

    1 Imports System

    2 Imports System.Diagnostics

    3 

    4 Friend Class Class1

    5     <STAThread()> _

    6     Shared Sub Main(ByVal args As String())

    7         Dim strRemark As String

    8         ' remarks to insert into the console output

    9 

   10         Console.WriteLine("all processes of the system")

   11         Console.WriteLine()

   12 

   13         Dim myProcesses As Process() = Process.GetProcesses()

   14         ' all processes into the array

   15 

   16         For Each p As Process In myProcesses

   17             If p.Id = Process.GetCurrentProcess().Id Then

   18                 ' the process id is unique in the system

   19                 strRemark = " < = my application"

   20             Else

   21                 strRemark = ""

   22             End If

   23 

   24             If p.ProcessName = _

   25             Process.GetCurrentProcess().ProcessName _

   26             AndAlso p.Id <> Process.GetCurrentProcess().Id Then

   27                 ' an additional instance of the same

   28                 ' application has the same name,

   29                 ' but an other process id

   30 

   31                 strRemark = " <= another instance of app"

   32             End If

   33 

   34             Console.WriteLine _

   35             ("{0}  {1}  {2}", p.ProcessName, p.Id, strRemark)

   36         Next p

   37 

   38         Console.WriteLine()

   39         Console.ReadLine()

   40         ' this ReadLine command is to hold the application open

   41     End Sub

   42 End Class

 

Happy Programming.

Doc

posted on Friday, July 14, 2006 1:45:21 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] Trackback
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