.NET Answers

ASP.NET, HTML, CSS, Visual Studio, CSharp, VB.NET and other programming items of interest.
Subscribe

Archive for April, 2008

Reflection -The Constructor

April 14, 2008 By: Dave Category: none

Remember, last week we started a series on using Reflection in our .NET applications.  We’ve loaded the assembly already, so the next step is creating the object.  Today’s tutorial will show how to instantiate the object using the default constructor and then quickly move on to using the parameterized constructor.

(more…)

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

The easiest way to create a SQL db from Code

April 11, 2008 By: Dave Category: none

(We’ll get back to the series on Reflection next week.)

So, I’ve started experimenting with replacing my TestComplete test scripts with CSharp test scripts.  This shouldn’t be too big of a deal since most of what I’m scripting are web applications and I can control that code via the WebBrowser control.

Well, the first thing my current script does is delete a database and recreate it.  When I went looking for how to create a database, all I could find was code similar to this:

(more…)

Reflection - Loading The Assembly

April 10, 2008 By: Dave Category: none

Recently, I received a question from a web visitor asking me to cover reflection.  So, I’m going to start a series on reflection.  Remember, if you have any questions you can ask me using the “Ask A Question” form.  Just look for the “Click Here to Ask A Question” button at the top of the page.

Today, we are going to cover loading the DLL…

(more…)

Serializable attribute vs Serializable Interface

April 09, 2008 By: Dave Category: none

Judging from the comments I received yesterday, it looks like we need to review  serialization in .NET.

(more…)

UnauthorizedAccessException writing to HKLM

April 08, 2008 By: Dave Category: none

Q. I’m trying to write to HKLM on a Vista computer using the following code:

Dim k As Microsoft.Win32.RegistryKey
k = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("software", True)
k = k.CreateSubKey("subkey1\testprogram")
k.SetValue("foo", "bar")

But, when I get to the last line, the UnauthorizedAccessException is thrown.  How do I fix this?

(more…)