[redland-dev] Problem using serializers in c#/Visual Studio 2005

Dan Pisarski DanP at libraryvideo.com
Thu Jul 27 20:58:04 UTC 2006


Ok, I figured out my stupid mistake on this one, having read URI was optional I figured I could pass in null - silly, I know.  Now passing in a true Redland.URI and making progress.
 
However I am now getting a different problem I am again hoping this list can help me with.
 
Once I got all the right data going into the underlying Redland C objects, I am getting back an error regarding protected memory:
 
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

This is on the line:
//---------------------------
int ret = librdf_serializer_serialize_model_to_file (handle, iname, base_uri.Handle, model.Handle);
from serializer.cs
//---------------------------

Thinking perhaps this was related to actually trying to write the file to the disk, I created a method to try it with 

//---------------------------
librdf_serializer_serialize_model_to_string, as follows:
[DllImport("librdf")]
static extern IntPtr librdf_serializer_serialize_model_to_string(HandleRef serializer, HandleRef base_uri, HandleRef model);
public string SerializeModelToString(Uri base_uri, Model model)
{
IntPtr returnedStringAsPtr;
returnedStringAsPtr = librdf_serializer_serialize_model_to_string(handle, base_uri.Handle, model.Handle);
string returnedString = Util.UTF8PtrToString(returnedStringAsPtr);
return returnedString;
}
//---------------------------

Which throws the same error on the line:
//---------------------------
returnedStringAsPtr = librdf_serializer_serialize_model_to_string(handle, base_uri.Handle, model.Handle);
Am I missing some setting for the Visual Studio 2005 project as a whole that makes this compatible?  Has anyone else experienced this?
//---------------------------

Again, here is the complete stack trace for this error:

at Redland.Serializer.librdf_serializer_serialize_model_to_string(HandleRef serializer, HandleRef base_uri, HandleRef model)
at Redland.Serializer.SerializeModelToString(Uri base_uri, Model model) in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandCshAssembly\\redland-bindings-1.0.4.1\\csharp\\Serializer.cs:line 107
at RedlandPoC.Form1.button1_Click(Object sender, EventArgs e) in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandPoC\\RedlandPoC\\Form1.cs:line 59
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at RedlandPoC.Program.Main() in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandPoC\\RedlandPoC\\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
Dan

________________________________________
From: redland-dev-bounces at lists.librdf.org on behalf of Dan Pisarski
Sent: Tue 7/25/2006 9:17 PM
To: redland-dev at lists.librdf.org
Subject: [redland-dev] Problem using serializers in c#/Visual Studio 2005
Hi everyone,
 
I am new to the list and thank you for your help. I am working with using the Redland library via the C# interface in Visual Studio 2005, and having a problem when trying to use the serializer object to generate a XML file from my model. Note I am working with my own compile of the C# interface due to the signature error I believe previously discussed on this list.  The only modifcation I made was to remove the assembly signing.
 
The error inside the C# library occurs on the following line:
  
int ret = librdf_serializer_serialize_model_to_file (handle, iname, base_uri.Handle, model.Handle);
The following error is thrown:
{"Object reference not set to an instance of an object."}
Seemingly on the "model" object - which is strange since it is passed into the function about 3 lines above, and while viewing the object in the dubugger it is not null and shows a size of 2 which matches my test model - which consists of 2 statements.
Here is the complete stack trace:
at Redland.Serializer.SerializeModel(String name, Uri base_uri, Model model) in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandCshAssembly\\redland-bindings-1.0.4.1\\csharp\\Serializer.cs:line 95
at RedlandPoC.Form1.button1_Click(Object sender, EventArgs e) in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandPoC\\RedlandPoC\\Form1.cs:line 52
at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n   at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)\r\n   at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at RedlandPoC.Program.Main() in C:\\Documents and Settings\\Daniel Pisarski\\My Documents\\Visual Studio 2005\\Projects\\RedlandPoC\\RedlandPoC\\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
 
I apperciate any insight anyone can lend into regarding this problem.
 
Dan Pisarski
Director of Digital Technology
Library Video Company
http://www.libraryvideo.com
 


More information about the redland-dev mailing list