Note: this post has been in my drafts for so long I’ve changed company and so this isn’t strictly relevant to me now. I developed this in my own time while working at my previous company and I figure it may come in useful to someone.
I’ve just been playing about with NHibernate and Advantage Database Server (ADS).
I’ve done some initial code to make NHibernate work with both DBF and ADT files.
I’ve put a sample solution up with both DBF and ADT configuration files. I’ve created a dialect and a driver for them. I’ve also found it necessary to create an ID provider in order to deal with the DBF’s. Since the NHibernate team recommends using a HiLo ID creator however it seems to make sense for the ADT dialect to also specify that by default. I found it necessary to create the ID provider because ADS provides an odd way to lock records that isn’t done via SQL, it’s done via their data provider classes.
This dialect does the bare minimum to support the sample I found at the start of my NHibernate In Action book. It does no more. It doesn’t do anything like type mapping or any of the other things a dialect normally does.
I’m not sure what to do with this next. I have tried running it against the NHibernate tests but there are so many failures because I’ve not implemented the basic things it’s a bit hard to see where to go.
For now I think I’ll see if I can use it in practice and then see where the holes are.
The one less than ideal thing that I’ve had to do is with the IIdentifierGenerator is basically copy the bits of code I wanted from the TableGenerator class and then modify them as required. I get the feeling that having to lock records in the manner I’ve needed to isn’t particularly common though.
To see the project and example download it from here. You also need to download the Advantage Data Provider from http://devzone.advantagedatabase.com/dz/content.aspx?key=20&Release=13&Product=4&Platform=11.
I’ve still yet to gain any reputation on Stack overflow but it’s already proving to be useful. It’s already answered some of my questions on MVC development and now it’s just saved me some pain and frustration while wondering why my code to use a FoxPro database isn’t working on my laptop.
As a side note on someone’s question Brian Behm has made a note that you need to be in 32 bit mode to use the Fox Pro Ole DB driver. That explains why I was getting the ‘
The 'vfpoledb' provider is not registered on the local machine.’ exception despite having installed the driver. All I need to do is add an x86 platform to my project and when I build with msbuild specify the platform using
/p:Platform=x86. I go through this pain so the users don’t have to!
The only down side is that it’s not exactly searchable. The only reason I found it was because I’d reached desperation search mode. I guess I should just ask the question properly on Stack overflow and then he can answer it again there and we’ll both gain some reputation points and it will be searchable for others.
I suppose it would be neat if you could break existing threads up on Stack overflow so that you can mark a comment as being the answer to a different question.
If you’re trying to run your .net program from a network share you’ve probably found out the hard way about the security permissions for .net programs.
A helpful post by Chunsheng Tang pointed my to some useful articles explaining what the deal is and how to make my program work but I’m still unsure about what to do about making it work from an installer.
For now I just want to prevent my program from dying with the embarrassing ‘your program has stopped working’ error.
My problem is primarily that the program dies before any of my code is executed so I can’t even setup an error handler. When the loader looks at my program’s dependencies it tries to load the dll’s in the same folder which causes a security exception.
My best idea at the moment is to use a loader program to load up the app dynamically so that it’s my code executing the assembly loading so that I can catch the exceptions and display my own error message.
A simple .net program with no external dll’s to load or files to read will load up fine. Then I try to run my program If it works then great, the program’s running; if not I catch the exception and display an error message explaining the situation.
Here is a snippet of my proof of concept to check that the idea would work. I still need to develop the idea to make it do everything I need but it does demonstrate that the idea works.
static class Program
/// The main entry point for the application.
static void Main()
public static void AppLoader(string app, string className)
bool loaded = false;
loaded = true;
MessageBox.Show("Unable to run from a network share");
protected static void RunApp(string program, string className)
Form f = null;
bool found = false;
Assembly a = Assembly.Load(program);
Module modules = a.GetModules();
foreach (Module m in modules)
Type types = m.FindTypes(Module.FilterTypeNameIgnoreCase, className);
foreach (Type t in types)
ConstructorInfo constructor = t.GetConstructor(Type.EmptyTypes);
if (constructor != null)
f = (Form)constructor.Invoke(null);
found = true;