diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
index 18afac22..79bcd0a5 100644
--- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
@@ -1227,16 +1227,20 @@ namespace IEC61850
/// If set to true the object reference is created without IED name.
public string GetObjectReference(bool withoutIedName = false)
{
- IntPtr objRefPtr = ModelNode_getObjectReferenceEx(self, IntPtr.Zero, withoutIedName);
+ IntPtr nativeMemory = Marshal.AllocHGlobal(130);
+
+ IntPtr objRefPtr = ModelNode_getObjectReferenceEx(self, nativeMemory, withoutIedName);
if (objRefPtr != IntPtr.Zero) {
string objRef = Marshal.PtrToStringAnsi(objRefPtr);
- Marshal.FreeHGlobal(objRefPtr);
+ Marshal.FreeHGlobal(nativeMemory);
return objRef;
}
else {
+ Marshal.FreeHGlobal(nativeMemory);
+
return null;
}
}
diff --git a/dotnet/server_goose_publisher/ServerExampleWithGoosePublisher.cs b/dotnet/server_goose_publisher/ServerExampleWithGoosePublisher.cs
index 4af291da..dba14bf1 100644
--- a/dotnet/server_goose_publisher/ServerExampleWithGoosePublisher.cs
+++ b/dotnet/server_goose_publisher/ServerExampleWithGoosePublisher.cs
@@ -49,11 +49,11 @@ namespace server_goose_publisher
{
if (cbEvent == 1)
{
- Console.WriteLine("GCB " + goCB.LN.GetName() + ":" + goCB.Name + " enabled");
+ Console.WriteLine("GCB " + goCB.LN.GetObjectReference() + ":" + goCB.Name + " enabled");
}
else
{
- Console.WriteLine("GCB " + goCB.LN.GetName() + ":" + goCB.Name + " disabled");
+ Console.WriteLine("GCB " + goCB.LN.GetObjectReference() + ":" + goCB.Name + " disabled");
}
}, null);