Is it possible to complie the source for .NET 4? I can get the source to compile in C# 2010 with
lots of wrnings but no errors. However, when I debug a statement such as
BerkeleyDb.Db my_db = new Db(DbCreateFlags.None);
a "TypeLoadException" is thrown:
"Could not load type 'BerkeleyDb.DB' from assembly 'libdb_dotNET45, Version=0.9.5.26694, Culture=neutral, PublicKeyToken=0f0d57806cebdc08'."
What am I doing wrong? Is it possibe to complie for .NET4 ??
Thanks for any help.
Tom Fisher
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you compile in Debug mode you should not get any errors or warnings.
I can reproduce your error on my Windo0ws 7 x64 OS, but I am at a loss why. My best guess is that the .NET 4.0 framework is stricter about loading unsafe structs with fixed binary layouts - especially with regards to platform pointer size.
Are you running on 32bit or 64bit OS?
Did you change any of the target platform settings?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've tried using all the different configs debug, release, x86, etc etc etc and I still keep getting the error
"TypeLoadException"
"Could not load type 'BerkeleyDb.DB' from assembly 'libdb_dotNET45, Version=0.9.5.26694, Culture=neutral, PublicKeyToken=0f0d57806cebdc08'."
when I try debugging the following statement:
BerkeleyDb.Db test_db = new Db(DbCreateFlags.None);
Again this is with C# 2010 Express version on a XP SP3 box x86
Any ideas??
Thanks,
Tom Fisher
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To get rid of warnings, use the latest code from CVS repository.
Try using it with .NET 2.0 as target, if you can, this should compile and work even under VS 2010.
Or, you could use a newer version of BerkeleyDB, which will have Oracle supported .NET API.
I will try to find out what the problem is, it might even be security related, but at this time I just don't know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I solved the problem. For some undocumented reason, .NET 4 does not like a self-referencing pointer for an unsafe struct. Please open up file DB.cs and change this declaration:
[StructLayout(LayoutKind.Sequential, Pack = Compile.PackSize)]
struct S_SECONDARIES
{
// DB_* lh_first;
// DB_ cannot be loaded under .NET 4.0 with a self-referencing pointer
// but we need it only to calculate offsets, so any pointer will do
int* lh_first;
}
S_SECONDARIES s_secondaries;
Then rebuild. This works for me.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
THANKS ! One more question. When I compile using any configuration, I get a bunch of errors similar to:
Error 1 Inconsistent accessibility: parameter type 'out BerkeleyDb.DB_SEQUENCE_STAT*' is less accessible than delegate 'BerkeleyDb.DB_SEQUENCE.StatFcn'
Then when I change the declaration for struct DB_SEQUENCE_STAT to public struct DB_SEQUENCE_STAT
the error is fixed. I have to do this for several structs and enums before I can get the project to compile.
Again, I'm using Visual C# Express edition on a x86 box with XP Pro SP3
Thanks for your help.
Tom Fisher
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to complie the source for .NET 4? I can get the source to compile in C# 2010 with
lots of wrnings but no errors. However, when I debug a statement such as
BerkeleyDb.Db my_db = new Db(DbCreateFlags.None);
a "TypeLoadException" is thrown:
"Could not load type 'BerkeleyDb.DB' from assembly 'libdb_dotNET45, Version=0.9.5.26694, Culture=neutral, PublicKeyToken=0f0d57806cebdc08'."
What am I doing wrong? Is it possibe to complie for .NET4 ??
Thanks for any help.
Tom Fisher
If you compile in Debug mode you should not get any errors or warnings.
I can reproduce your error on my Windo0ws 7 x64 OS, but I am at a loss why. My best guess is that the .NET 4.0 framework is stricter about loading unsafe structs with fixed binary layouts - especially with regards to platform pointer size.
Are you running on 32bit or 64bit OS?
Did you change any of the target platform settings?
Thanks for the quick reply. I get a bunch of errors like:
"Inconsistent accessibility: parameter type 'out BerkeleyDb.DB_SEQUENCE_STAT*' is less accessible than delegate 'BerkeleyDb.DB_SEQUENCE.StatFcn"
When I modify the access(s) of BerkeleyDb.DB_SEQUENCE_STAT(et al) to public
the errors are fixed and everyting will compile but with warnings.
I am doing this on an XP SP3 32 bit OS and Visual C# 2010 Express version. How should
I set this up?
Thanks again,
Tom Fisher
I've tried using all the different configs debug, release, x86, etc etc etc and I still keep getting the error
"TypeLoadException"
"Could not load type 'BerkeleyDb.DB' from assembly 'libdb_dotNET45, Version=0.9.5.26694, Culture=neutral, PublicKeyToken=0f0d57806cebdc08'."
when I try debugging the following statement:
BerkeleyDb.Db test_db = new Db(DbCreateFlags.None);
Again this is with C# 2010 Express version on a XP SP3 box x86
Any ideas??
Thanks,
Tom Fisher
To get rid of warnings, use the latest code from CVS repository.
Try using it with .NET 2.0 as target, if you can, this should compile and work even under VS 2010.
Or, you could use a newer version of BerkeleyDB, which will have Oracle supported .NET API.
I will try to find out what the problem is, it might even be security related, but at this time I just don't know.
I think I solved the problem. For some undocumented reason, .NET 4 does not like a self-referencing pointer for an unsafe struct. Please open up file DB.cs and change this declaration:
to the following declaration:
Then rebuild. This works for me.
THANKS ! One more question. When I compile using any configuration, I get a bunch of errors similar to:
Error 1 Inconsistent accessibility: parameter type 'out BerkeleyDb.DB_SEQUENCE_STAT*' is less accessible than delegate 'BerkeleyDb.DB_SEQUENCE.StatFcn'
Then when I change the declaration for struct DB_SEQUENCE_STAT to public struct DB_SEQUENCE_STAT
the error is fixed. I have to do this for several structs and enums before I can get the project to compile.
Again, I'm using Visual C# Express edition on a x86 box with XP Pro SP3
Thanks for your help.
Tom Fisher
Are you sure you have checked out the latest code from CVS?
I have no errors or warnings when compiling (in debug mode).
You will need to re-apply the change I posted, as it is not in CVS yet.
Actually, I just committed the change to CVS.
I'm using the latest .zip file. Your fix works well.
THANK YOU !!!!!!!
Tom Fisher
The latest zip is not the latest code. You will need a CVS client to get it.