Exploring the depths and potentials of ASP.NET RSS 2.0 or Subscribe to .BenRush by Email
 Tuesday, July 10, 2007

We've all been pounded with "beware of SQL Injection Attacks" - yet I found a rather nice blog post here: http://blogs.msdn.com/dglover/archive/2005/06/01/423727.aspx that hands out a nice filter method for SQL Server. You might as well have a look and see if you can introduce it into your stored procedures....


kick it on DotNetKicks.com
Monday, July 09, 2007 11:01:48 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
.Net Runtime | Database | Programming
 Sunday, July 08, 2007

This last TechEd I went to a session on getting work as an independent consultant and ever since then I have been really focused on optimizing not only my own searching but that of other consultants. A couple more things I would like to mention:

1. If you have no problem getting certified for a security clearence, the government is hiring right now. People at the session really pushed the fact that the government is really looking into independent consulting at the moment (for one reason or another), and that it might be a good opportunity for independent developers.
2. Charity is, suprisingly, a good option. Even though you may not make a lot of money (or any) helping out a charity, charities have benefactors - people that donate money - and your good deeds go noticed. Benefactors do have money; doing a good job for something a rich person cares about might have its benefits.
3. Staffing agencies are there to help. Staffing agencies like this one: http://www.teksystems.com/Services/Staffing-Services/Default.aspx are there to link up parties. These people, obviously, take their cut, but it's a great way to get started. Remember - beggars can't be choosers.

...just a few more things to think about.


kick it on DotNetKicks.com
Sunday, July 08, 2007 12:29:33 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
Programming | Ranting | Business and Consulting
 Sunday, July 01, 2007

http://msdn2.microsoft.com/en-us/library/ms364069(vs.80).aspx

Writing code that is fully interoperable with two different runtimes can blow; 'nuff said. The single-most valuable thing to remember when doing COM interop (in my opinion) is to add your damn .NET module to the GAC. Why?

The reason lies in the internals of COM, and if you've ever had the distinct pleasure of pounding your head against the desk while working on COM you'll quickly understand what I'm trying to say. COM was built with the ideals of interoperability in mind: so long as the two, distinct components stuck to a particular contract-based communcation (through "interfaces") then everything worked nicely.

In COM to get at a particular bit of functionality (which is exposed via an "interface") you must get at the Com Class (coclass) which implements the interface. A particular COM server houses the Com Class (coclass) which implements the interface. Basically, to get at functionality, then, you must locate the physical module, then ask the physical module to activate a particular "object" and then ask the "object" for an interface pointer to the functionality; the rest is done through vtable pointer arithmetic (this is all if you're using "IUnknown" semantics, otherwise the game is slighty different).

.NET interops with COM by having the mscorlib.dll module be the server - it is responsible for loading the necessary DLL files that implement your .NET functionality and doing all the proper dirty work of interoperating with COM. Say you have a COM plugin, then, for some application - but the plugin is written in VB.NET. The main application attempts attempts to create a com instance (through CoCreateInstance()) of your .NET module - this routes the COM runtime to Mscorlib.dll which attempts to locate your DLL; however, how does Mscorlib.dll find it? Well, if you haven't placed it directly next to (in the same directory as) the main application or in the GAC, MScorlib.dll will not be able to find your module and you're, effectively, "dot screwed".

....by placing the module in the GAC you'll be able to guarantee mscorlib.dll will find your module.


kick it on DotNetKicks.com
Sunday, July 01, 2007 5:33:31 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
.Net Runtime | General .Net | Programming | Under the Hood

I'm a consultant, and as a consultant I spend a great deal of time concerning myself with the "next job". I may not always be a consultant (I don't believe it's related in any way shape or form to my eagerness to be one, just that times change, etc) but for the time being I am one and so must constantly be on the outlook for the next great "gig".

How do you go about getting a consulting job? Well, for me the challenge is my locality. I'm located in Nebraska which, for the most part, is a relatively barren wasteland for modern technology. Most of my "gigs" have been acquired through word of mouth and diligence on my part to help people in times of need when they requested it - you treat someone well and they'll treat you well back, it's the basic law of the land.

First - I would not look on sites like rentacoder.com. I have tried it, and I don't like it. Why? The reason is simple, for the most part people you will find on rentacoder (on both ends of the spectrum: developer or "buyer") are unrealistic. It's not their fault; they're not "stupid" in any way shape and or form, they're just somewhat naive about the nature of software and how much it costs to develop something correct. Take this for example: say you find someone on there who bids for a full-featured ASP.NET site for $20.00 (I've seen it); chances are they will be back bidding again in a month or two to correct the myriad of mistakes the $20.00 wunderkind caused.

Oh well.

Second - I would join local organizations, clubs, etc. and become active members of them and rub elbows with business-folk. One thing we, as developers, are relatively poor at is communicating with the outside world. You can make a business person fall in love with you if you express, in some way, an appreciation for their situation and, especially, a firm understanding of it. At the end of the day everyone is out for the same thing in business: to make money. Being an active member of this world will clue business people onto you as someone who "understands" the needs and processes of real-world business software. Remember, the stereotype most business dudes have of us is that we're cowboys - loose cannons who sleep by day and hack by night. For the most part they treat you as a risk - you wield a black magic that they do not understand; do not use this force for evil, use it for good.

Third - Do things with the end in mind. You have a choice as to whether you get yourself certified as a Microsoft developer or master your latest XBOX game. Look at your resume' and think about what it says about you - as a person. Does it project someone willing to explore the depths of a project for someone, or not?

Fourth - have a reachable presence. I'm not promising I'll be doing this consulting stuff in a year, but I am promising that as I continue to write, and continue to learn, I will continue to grow my presence/influence wherever and however I can.  This means things like blogging, speaking, writing for magazines, etc. The first step is always advertising your presence because without a presence you cannot be reached, period (well, duh).

Fifth - try your damndest to say atop of the needs of your area. Note how I say, "Of your area" - this is extraordinarily important. Areas differ on their needs and requirements for software; different places require different talents - you will succeed if you have a good rap sheet and expertise on those needs. Consider that and ask around, talk, discover, etc.

...I think the most important thing to take away is opening the lines of communciation, being accessible and being real. Believe it or not, but if you can make those things happen you can probably (probably) make it as a software consultant.


kick it on DotNetKicks.com
Sunday, July 01, 2007 4:16:27 PM (Central Standard Time, UTC-06:00)  #    Comments [7] - Trackback
Computing | Programming | Ranting
 Thursday, April 12, 2007

I quickly through this sample together because someone in the newsgroups wanted a way to create a filesystem view through the ASP.Net TreeView control. Note: I'm not touching this with icons or any other niceness, that's an exercise left to the reader:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<script runat="server" language="C#">
    protected void Page_Load(object sender, EventArgs e)
    {
        System.IO.DirectoryInfo di =
            new System.IO.DirectoryInfo(@"c:\mydirectory\mydirectoryschild\");
        TreeNode root = new TreeNode(di.Name);
        this.TreeView1.Nodes.Add(root);
        HydrateTree(di, root);
    }

    private void HydrateTree(System.IO.DirectoryInfo dir, TreeNode parent)
    {
        foreach (System.IO.FileInfo file in dir.GetFiles())
        {
            parent.ChildNodes.Add(new TreeNode(file.Name));
        }
        foreach (System.IO.DirectoryInfo di in dir.GetDirectories())
        {
            TreeNode child = new TreeNode(di.Name);
            parent.ChildNodes.Add(child);
            HydrateTree(di, child);
        }
        return;
    }
</script>
<asp:TreeView ID="TreeView1" runat="server">
</asp:TreeView>

This is what it looks like on my machine:



Recommended reading:


kick it on DotNetKicks.com
Thursday, April 12, 2007 7:37:08 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
ASP.Net | Programming
 Tuesday, April 10, 2007

Kind of an interesting mental exercise. Say you wanted to enumerate all the classes in any particular namespace. Unfortunately there doesn't appear to be a way to say, "Get all classes in a namespace" using reflection, so you kind of have to roll your own implementation. But, this is how I did it....

namespace TestingGroundsCSharpConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly a = Assembly.GetExecutingAssembly();
            List<String> namespaces = new List<string>();
            foreach (Type t in a.GetTypes())
            {
                if (t.Namespace == "TestingGroundsCSharpConsole")
                    namespaces.Add(t.Name);
            }

            foreach (String s in namespaces)
                Console.WriteLine(s);

            Console.ReadLine();

            return;
        }
    }

    class Class1
    {
        private Int32 _myInt;
    }

    class Class2
    {
        private Int32 _myotherInt;
    }
}

....the output is

Program
Class1
Class2



kick it on DotNetKicks.com
Tuesday, April 10, 2007 10:07:02 PM (Central Standard Time, UTC-06:00)  #    Comments [1] - Trackback
Programming | .Net Runtime

You more than likely get this exception when you attempt to use the "My.Settings" object through ASP.Net. Settings scoped for the user are valid for WinForms or other such desktop applications which typically run under a particular user account, but ASP.Net accounts run, usually, under a special server or ASP.Net account - therefore this object will throw an exception when used in this context.

The best way around this is to use ConfigurationManager.AppSettings for settings, or Profiles for per-user configuration in ASP.Net 2.0.


kick it on DotNetKicks.com
Tuesday, April 10, 2007 6:57:55 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
ASP.Net | Programming

I saw a question in the newsgroups about this and I thought I would post about it right quick; "how do you manually set focus with javascript". Using .Net it's easy, you simply call .Focus() on a server control:

this.LinkButton1.Focus();

But if you have to do it from script within a page itself, you do it this way:

<html id="total" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body id="Body" onload="document.form1.Text2.focus();">
    <form id="form1" runat="server" style="width:1000px;height:1000px;" >
        <div  >
           <input id="Text1" type="text" /><input id="Text2" type="text"/>
        </div>
    </form>
</body>
</html>

Notice the onload event within the body. This will effectively focus the cursor within Text2. Obviously you don't have to limit it to the body onload event, you can do it from any event or any script; I just did it there from my example.

Easy as cake.


kick it on DotNetKicks.com
Tuesday, April 10, 2007 6:46:23 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
ASP.Net | JavaScript | Programming

Computers Blogs - Blog Top Sites

Archive
<August 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Benjamin Rush
Sign In
Statistics
Total Posts: 444
This Year: 0
This Month: 0
This Week: 0
Comments: 127
Themes
Pick a theme:
All Content © 2008, Benjamin Rush
DasBlog theme 'Business' created by Christoph De Baene (delarou)