Sean Lynch

July 7, 2008

ScriptControl question

Filed under: .Net,Development,Work — Sean Lynch @ 5:09 pm

As of late I have gotten a chance to use the ASP.Net AJAX extenders and script controls, and so far am really liking how they work, though it would be nice if adding the .js was a little cleaner then manually adding them to the assembly wether in the AssemblyInfo.cs or the controls cs file.

I have to say I really like the extender and script controls that come with the ASP.NET AJAX. They really are so much nicer to work with then building up Javascript strings in the CS file of the server control.

I do have a question about them though. One of the ScriptControls I made uses a webservice to pull data if the service name is set. At the moment I have it dynamically registering an JSON script service based webservice. Unfortunately I have found that this is not an optimal solution since the name of the Javascript object created by the ScriptService changes depending on the namespace and class name of the service.

I am sure that there is a better way to do this, but I am not exactly certain of it. Any suggestions or links would be appreciated.

December 12, 2007

I think the 3.5 framework might be the straw

Filed under: .Net,Work — Sean Lynch @ 12:57 am

Yesterday my boss had me upgrade the project files of our main app to use Visual Studio 2008.

While doing this the migration wizard asked if I wanted to upgrade the app to work against the .Net 3.5 framework. He had said to just migrate the solution files for now, and later when there was time we would upgrade the framework version.

Then he asked something I hadn’t really thought about.

“Does the .Net 3.5 framework support Windows 2000?”

And its been quite a while since a single question had essentially ruined my day, but this one pretty much had. I guess I should say that it was the “no” that I responded with that really did it, since it meant that it will likely be years until we upgrade it (we officially dropped support for SQL7 around June). The worst part is that not upgrading the framework for the most part the right decision for the company, as many of our existing customers use Windows 2000.

Unlike the 2.0 framework, which because of having our own framework essentially I could only really make use of generics, the new features in 3.5 framework (and inclusion of 3.0) had a lot of promise. However, since most of what I wanted to use it for could be done without it the 3.x features with some extra work, I find myself unable to come up with a strong enough case (though I really wish I could) that would counter act the possible loss of existing customers.

Unfortunately there is one other downside to this decision which, because of the environment that my boss has created, I doubt will come up until it is to late. Might expand on this at a later time, but I really want to get back to playing with the MVC framework right now.

 

Technorati Tags:

September 16, 2007

Blue screen in stereo

Filed under: Work — Sean Lynch @ 5:49 pm

Had my first ever blue screen on my computer at work. Unfortunately, I think this may be foretelling a problem with the machine, since its my first blue screen since I started running XP that wasn’t related to video drivers.

 DualBluescreen

The picture really doesn’t do it justice, but there really was something impressive and humorous (coworkers really liked it) about seeing this. 

Update: Turned out to be bad memory, so now Im running on 1GB at work (with a fix in the works).

September 10, 2007

I wish C# 3.0 was here already

Filed under: .Net,Development,Work — Sean Lynch @ 2:18 am

I was reading IHttpContext And Other Interfaces For Your Duck Typing Benefit over on Haacked. It reminded my of something I did Thursday, which made me wish that .Net 3.5 was already usable.

I actually finally convinced my boss to let me try to automate at least some of the testing. So first order of business, change our the SQL installer program we use to allow it run without user interaction.

After a good amount of refactoring of the monolithic control function, I get that part working. It can now do everything it needs to do by passing in all the stuff I need on the command line. After answering some several questions from the junior developers, several of which they answered them selves during the course of the conversation, I start to move onto making it into something useful.

I decide to make a simple API that I could use to inside of programs, so I can make a quick proof of concept for my boss who is skeptical that it would be feasible to make tests for the SQL (business logic). Something along the lines of here are your options, start and let me know how it went. That’s when the fun started, its a single executable file and “needs” to stay that way (which I agree with overall). After my momentary amnesia about not being able to reference exe files, I decide that I am going to use reflection.

My first attempt went something like:

//The installer has a start method
interface IInstaller{void Start();}
public IInstaller Bind()
{
	Assembly assembly = Assembly.LoadFile("<Path>");
	Type type = assembly.GetType("namespace.frm");
	ConstructorInfo constructorInfo = type.GetConstructor(new Type[]{});
	IInstaller installer = (IInstaller)constructorInfo.Invoke(new object[]{});
}

That didnt work so well, since while namespace.frm object had a Start method, it wasn’t from that interface, and shared no assemblies in common that I could use an interface from. In the end I decided to make a wrapper class that would take the object and make use a delegate to keep a reference to the Start method.

Something close to this:

public interface IInstaller{void Start();}
public class InstallerWrapper:IInstaller
{
	private delegate void StartMethod();
	StartMethod startDelegate;
	object _installer;
	public InstallerWrapper(object installer)
	{
		_installer = installer;
		startDelegate = (StartMethod)Delegate.CreateDelegate(typeof(StartMethod), installer, "Start");
	}
	public void Start()
	{
		startDelegate();
	}
}
public IInstaller Bind()
{
	Assembly assembly = Assembly.LoadFile("<Path>");
	Type type = assembly.GetType("namespace.frm");
	ConstructorInfo constructorInfo = type.GetConstructor(new Type[]{});
	return new InstallerWrapper(constructorInfo.Invoke(new object[]{}));
}

Thinking about what I have read about the implementation of it in C# 3.0 I would likely have needed to do it this way anyways, since atleast from what I have read it is a compile time feature. Haven’t tested it yet on my VS 2008 beta VM yet though, so I could be wrong.

Oh, and please forgive the formatting of the code, haven’t done it much yet.

Powered by WordPress