>From 9b40a4db5cb49cc458e6d76bf9a60c0a9b6fe0f5 Mon Sep 17 00:00:00 2001
From: Arnaud <arnaud.champion@devatom.fr>
Date: Tue, 19 Oct 2010 16:01:39 +0200
Subject: [PATCH] Add Visual Studio 2010 and MonoDevelop solutions
 Add examples "virCOnnectOpenAuth" for Visual Studio and MonoDevelop

---
 Libvirt.cs                 |  468 +++++++++++++++++++++++---------------------
 LibvirtBindings.csproj     |   63 ------
 LibvirtBindings.sln        |   20 --
 LibvirtError.cs            |   18 +-
 LibvirtTypes.cs            |  128 ++++++++++--
 Properties/AssemblyInfo.cs |   36 ----
 6 files changed, 358 insertions(+), 375 deletions(-)
 delete mode 100644 LibvirtBindings.csproj
 delete mode 100644 LibvirtBindings.sln
 delete mode 100644 Properties/AssemblyInfo.cs

diff --git a/Libvirt.cs b/Libvirt.cs
index 0a18328..dcba9b3 100644
--- a/Libvirt.cs
+++ b/Libvirt.cs
@@ -17,6 +17,18 @@ namespace LibvirtBindings
     public class libVirt
     {
         private const int MaxStringLength = 1024;
+#if WINDOWS
+        private const string LibvirtDllImportName = "libvirt-0.dll";
+        private const string StrDupDllImportName = "msvcrt.dll";
+        private const string StrDupEntryPoint = "_strdup";
+#else
+        private const string LibvirtDllImportName = "libvirt.so.0";
+        private const string StrDupDllImportName = "libc.so.6";
+        private const string StrDupEntryPoint = "strdup";
+#endif
+        [DllImport(StrDupDllImportName, EntryPoint = StrDupEntryPoint, CallingConvention=CallingConvention.Cdecl)]
+        public static extern IntPtr StrDup(IntPtr strSource);
+
 
         #region Connect
         /// <summary>
@@ -24,23 +36,23 @@ namespace LibvirtBindings
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>0 in case of success or -1 in case of error.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectClose(IntPtr conn);
         /// <summary>
         /// Provides capabilities of the hypervisor / driver.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>NULL in case of error, or an XML string defining the capabilities. The client must free the returned string after use.</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virConnectGetCapabilities(IntPtr conn);
         /// <summary>
         /// This returns the system hostname on which the hypervisor is running (the result of the gethostname system call). If we are connected to a remote system, then this returns the hostname of the remote system.
         /// </summary>
         /// <param name="conn">pointer to a hypervisor connection</param>
         /// <returns>the hostname which must be freed by the caller, or NULL if there was an error.</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virConnectGetHostname(IntPtr conn);
         /// <summary>
         /// Provides @libVer, which is the version of libvirt used by the daemon running on the @conn host
@@ -48,7 +60,7 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="libVer">returns the libvirt library version used on the connection (OUT)</param>
         /// <returns>-1 in case of failure, 0 otherwise, and values for @libVer have the format major * 1,000,000 + minor * 1,000 + release.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectGetLibVersion(IntPtr conn, ref ulong libVer);
         /// <summary>
         /// Provides the maximum number of virtual CPUs supported for a guest VM of a specific type. The 'type' parameter here corresponds to the 'type' attribute in the domain element of the XML.
@@ -56,23 +68,23 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="type">value of the 'type' attribute in the domain element</param>
         /// <returns>the maximum of virtual CPU or -1 in case of error.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectGetMaxVcpus(IntPtr conn, string type);
         /// <summary>
         /// Get the name of the Hypervisor software used.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>NULL in case of error, a static zero terminated string otherwise. See also: http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virConnectGetType(IntPtr conn);
         /// <summary>
         /// This returns the Uri (name) of the hypervisor connection. Normally this is the same as or similar to the string passed to the virConnectOpen/virConnectOpenReadOnly call, but the driver may make the Uri canonical. If name == NULL was passed to virConnectOpen, then the driver will return a non-NULL Uri which can be used to connect to the same hypervisor later.
         /// </summary>
         /// <param name="conn">pointer to a hypervisor connection</param>
         /// <returns>the Uri string which must be freed by the caller, or NULL if there was an error.</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virConnectGetURI(IntPtr conn);
         /// <summary>
         /// Get the version level of the Hypervisor running. This may work only with hypervisor call, i.e. with privileged access to the hypervisor, not with a Read-Only connection.
@@ -80,21 +92,21 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="hvVer">return value for the version of the running hypervisor (OUT)</param>
         /// <returns>-1 in case of error, 0 otherwise. if the version can't be extracted by lack of capacities returns 0 and @hvVer is 0, otherwise @hvVer value is major * 1,000,000 + minor * 1,000 + release</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectGetVersion(IntPtr conn, ref ulong hvVer);
         /// <summary>
         /// Determine if the connection to the hypervisor is encrypted
         /// </summary>
         /// <param name="conn">pointer to the connection object</param>
         /// <returns>1 if encrypted, 0 if not encrypted, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectIsEncrypted(IntPtr conn);
         /// <summary>
         /// Determine if the connection to the hypervisor is secure A connection will be classed as secure if it is either encrypted, or running over a channel which is not exposed to eavesdropping (eg a UNIX domain socket, or pipe)
         /// </summary>
         /// <param name="conn">pointer to the connection object</param>
         /// <returns>1 if secure, 0 if secure, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectIsSecure(IntPtr conn);
         /// <summary>
         /// list the defined but inactive domains, stores the pointers to the names in @names
@@ -103,7 +115,7 @@ namespace LibvirtBindings
         /// <param name="names">pointer to an array to store the names</param>
         /// <param name="maxnames">size of the array</param>
         /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListDefinedDomains(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// list the defined but inactive domains, stores the pointers to the names in @names
@@ -128,7 +140,7 @@ namespace LibvirtBindings
         /// <param name="names">array to collect the list of names of interfaces</param>
         /// <param name="maxnames">size of @names</param>
         /// <returns>the number of interfaces found or -1 in case of error </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListDefinedInterfaces(IntPtr conn, IntPtr names, int maxnames);
         ///<summary>
         /// Collect the list of defined (inactive) physical host interfaces, and store their names in @names.
@@ -153,7 +165,7 @@ namespace LibvirtBindings
         /// <param name="names">pointer to an array to store the names</param>
         /// <param name="maxnames">size of the array</param>
         /// <returns>the number of names provided in the array or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListDefinedNetworks(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// list the inactive networks, stores the pointers to the names in @names
@@ -178,7 +190,7 @@ namespace LibvirtBindings
         /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
         /// <param name="maxnames">size of the names array</param>
         /// <returns>0 on success, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListDefinedStoragePools(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// Provides the list of names of inactive storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
@@ -203,7 +215,7 @@ namespace LibvirtBindings
         /// <param name="ids">array to collect the list of IDs of active domains</param>
         /// <param name="maxids">size of @ids</param>
         /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectListDomains(IntPtr conn, int[] ids, int maxids);
         /// <summary>
         /// Collect the list of active physical host interfaces, and store their names in @names
@@ -212,7 +224,7 @@ namespace LibvirtBindings
         /// <param name="names">array to collect the list of names of interfaces</param>
         /// <param name="maxnames">size of @names</param>
         /// <returns>the number of interfaces found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListInterfaces(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// Collect the list of active physical host interfaces, and store their names in @names
@@ -237,7 +249,7 @@ namespace LibvirtBindings
         /// <param name="names">array to collect the list of names of active networks</param>
         /// <param name="maxnames">size of @names</param>
         /// <returns>the number of networks found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListNetworks(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// Collect the list of active networks, and store their names in @names
@@ -262,7 +274,7 @@ namespace LibvirtBindings
         /// <param name="uuids">Pointer to an array to store the UUIDs</param>
         /// <param name="maxuuids">size of the array.</param>
         /// <returns>the number of UUIDs provided in the array, or -1 on failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListSecrets(IntPtr conn, IntPtr uuids, int maxuuids);
         /// <summary>
         /// List UUIDs of defined secrets, store pointers to names in uuids.
@@ -287,7 +299,7 @@ namespace LibvirtBindings
         /// <param name="names">array of char * to fill with pool names (allocated by caller)</param>
         /// <param name="maxnames">size of the names array</param>
         /// <returns>0 on success, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virConnectListStoragePools(IntPtr conn, IntPtr names, int maxnames);
         /// <summary>
         /// Provides the list of names of active storage pools upto maxnames. If there are more than maxnames, the remaining names will be silently ignored.
@@ -310,70 +322,70 @@ namespace LibvirtBindings
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfDefinedDomains(IntPtr conn);
         /// <summary>
         /// Provides the number of defined (inactive) interfaces on the physical host.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of defined interface found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfDefinedInterfaces(IntPtr conn);
         /// <summary>
         /// Provides the number of inactive networks.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of networks found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfDefinedNetworks(IntPtr conn);
         /// <summary>
         /// Provides the number of inactive storage pools
         /// </summary>
         /// <param name="conn">pointer to hypervisor connection</param>
         /// <returns>the number of pools found, or -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfDefinedStoragePools(IntPtr conn);
         /// <summary>
         /// Provides the number of active domains.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of domain found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfDomains(IntPtr conn);
         /// <summary>
         /// Provides the number of active interfaces on the physical host.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of active interfaces found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfInterfaces(IntPtr conn);
         /// <summary>
         /// Provides the number of active networks.
         /// </summary>
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <returns>the number of network found or -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfNetworks(IntPtr conn);
         /// <summary>
         /// Fetch number of currently defined secrets.
         /// </summary>
         /// <param name="conn">virConnect connection</param>
         /// <returns>the number currently defined secrets.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfSecrets(IntPtr conn);
         /// <summary>
         /// Provides the number of active storage pools
         /// </summary>
         /// <param name="conn">pointer to hypervisor connection</param>
         /// <returns>the number of pools found, or -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectNumOfStoragePools(IntPtr conn);
         /// <summary>
         /// This function should be called first to get a connection to the Hypervisor and xen store
         /// </summary>
         /// <param name="name">Uri of the hypervisor</param>
         /// <returns>pointer to the connection</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virConnectOpen(string name);
 
         ///<summary>
@@ -383,22 +395,22 @@ namespace LibvirtBindings
         ///<param name="auth">Authenticate callback parameters</param>
         ///<param name="flags">Open flags</param>
         ///<returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
-        [DllImport("libvirt-0.dll")]
-        public static extern IntPtr virConnectOpenAuth(string name, [In] ref virConnectAuth auth, int flags);
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        public static extern IntPtr virConnectOpenAuth(string name, ref virConnectAuth auth, int flags);
 
         /// <summary>
         /// This function should be called first to get a restricted connection to the library functionalities. The set of APIs usable are then restricted on the available methods to control the domains. See virConnectOpen for notes about environment variables which can have an effect on opening drivers
         /// </summary>
         /// <param name="name">Uri of the hypervisor</param>
         /// <returns>a pointer to the hypervisor connection or NULL in case of error URIs are documented at http://libvirt.org/uri.html </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virConnectOpenReadOnly(string name);
         /// <summary>
         /// Increment the reference count on the connection. For each additional call to this method, there shall be a corresponding call to virConnectClose to release the reference count, once the caller no longer needs the reference to this object. This method is typically useful for applications where multiple threads are using a connection, and it is required that the connection remain open until all threads have finished using it. ie, each new thread using a connection would increment the reference count.
         /// </summary>
         /// <param name="conn">the connection to hold a reference on</param>
         /// <returns>0 in case of success, -1 in case of failure</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virConnectRef(IntPtr conn);
         #endregion
 
@@ -409,7 +421,7 @@ namespace LibvirtBindings
         /// <param name="domain">pointer to domain object</param>
         /// <param name="xml">pointer to XML description of one device</param>
         /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainAttachDevice(IntPtr domain, string xml);
         /// <summary>
         /// Attach a virtual device to a domain, using the flags parameter to control how the device is attached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is made based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be allocated to the active domain instance only and is not added to the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be allocated to the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports modifying the persisted device allocation.
@@ -418,7 +430,7 @@ namespace LibvirtBindings
         /// <param name="xml">pointer to XML description of one device</param>
         /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
         /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainAttachDeviceFlags(IntPtr domain, string xml, uint flags);
 
         // TODO virDomainBlockPeek
@@ -431,7 +443,7 @@ namespace LibvirtBindings
         /// <param name="stats">block device stats (returned)</param>
         /// <param name="size">size of stats structure</param>
         /// <returns>0 in case of success or -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainBlockStats(IntPtr dom, string path, virDomainBlockStatsStruct stats, int size);
         /// <summary>
         /// This method will dump the core of a domain on a given file for analysis. Note that for remote Xen Daemon the file path will be interpreted in the remote host.
@@ -440,7 +452,7 @@ namespace LibvirtBindings
         /// <param name="to">path for the core file</param>
         /// <param name="flags">extra flags, currently unused</param>
         /// <returns>0 in case of success and -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainCoreDump(IntPtr domain, string to, int flags);
         /// <summary>
         /// Launch a defined domain. If the call succeed the domain moves from the defined to the running domains pools.
@@ -451,11 +463,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainCreate(IntPtr domain);
         /// <summary>
         /// Launch a new guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc().
-        /// This function may requires privileged access to the hypervisor. The domain is not persistent,
+        /// This function may requires privileged access to the hypervisor. The domain is not persistent, 
         /// so its definition will disappear when it is destroyed, or if the host is restarted (see virDomainDefineXML() to define persistent domains).
         /// </summary>
         /// <param name="conn">
@@ -470,10 +482,10 @@ namespace LibvirtBindings
         /// <returns>
         /// A new domain object or NULL in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainCreateXML(IntPtr conn, string xmlDesc, uint flags);
         /// <summary>
-        /// Define a domain, but does not start it. This definition is persistent, until explicitly undefined with virDomainUndefine().
+        /// Define a domain, but does not start it. This definition is persistent, until explicitly undefined with virDomainUndefine(). 
         /// A previous definition for this domain would be overriden if it already exists.
         /// </summary>
         /// <param name="conn">
@@ -485,11 +497,11 @@ namespace LibvirtBindings
         /// <returns>
         /// NULL in case of error, a pointer to the domain otherwise.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainDefineXML(IntPtr conn, string xml);
         /// <summary>
-        /// Destroy the domain object. The running instance is shutdown if not down already
-        /// and all resources used by it are given back to the hypervisor.
+        /// Destroy the domain object. The running instance is shutdown if not down already 
+        /// and all resources used by it are given back to the hypervisor. 
         /// This does not free the associated virDomainPtr object. This function may require privileged access
         /// </summary>
         /// <param name="domain">
@@ -498,7 +510,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainDestroy(IntPtr domain);
         /// <summary>
         /// Destroy a virtual device attachment to backend.
@@ -512,7 +524,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainDetachDevice(IntPtr domain, string xml);
         /// <summary>
         /// Detach a virtual device from a domain, using the flags parameter to control how the device is detached. VIR_DOMAIN_DEVICE_MODIFY_CURRENT specifies that the device allocation is removed based on current domain state. VIR_DOMAIN_DEVICE_MODIFY_LIVE specifies that the device shall be deallocated from the active domain instance only and is not from the persisted domain configuration. VIR_DOMAIN_DEVICE_MODIFY_CONFIG specifies that the device shall be deallocated from the persisted domain configuration only. Note that the target hypervisor must return an error if unable to satisfy flags. E.g. the hypervisor driver will return failure if LIVE is specified but it only supports removing the persisted device allocation.
@@ -521,7 +533,7 @@ namespace LibvirtBindings
         /// <param name="xml">pointer to XML description of one device</param>
         /// <param name="flags">an OR'ed set of virDomainDeviceModifyFlags</param>
         /// <returns>0 in case of success, -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainDetachDeviceFlags(IntPtr domain, string xml, uint flags);
         /// <summary>
         /// Free the domain object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
@@ -532,7 +544,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainFree(IntPtr domain);
         /// <summary>
         /// Provides a boolean value indicating whether the domain configured to be automatically started when the host machine boots.
@@ -546,12 +558,12 @@ namespace LibvirtBindings
         /// <returns>
         /// -1 in case of error, 0 in case of success.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetAutostart(IntPtr domain, out int autostart);
         /// <summary>
-        /// Provides the connection pointer associated with a domain.
-        /// The reference counter on the connection is not increased by this call.
-        /// WARNING: When writing libvirt bindings in other languages, do not use this function.
+        /// Provides the connection pointer associated with a domain. 
+        /// The reference counter on the connection is not increased by this call. 
+        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
         /// Instead, store the connection and the domain object together.
         /// </summary>
         /// <param name="dom">
@@ -560,7 +572,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The <see cref="IntPtr"/>or NULL in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainGetConnect(IntPtr dom);
         /// <summary>
         /// Get the hypervisor ID number for the domain.
@@ -571,10 +583,10 @@ namespace LibvirtBindings
         /// <returns>
         /// The domain ID number or (unsigned int) -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetID(IntPtr domain);
         /// <summary>
-        /// Extract information about a domain. Note that if the connection used to get the domain is limited only a
+        /// Extract information about a domain. Note that if the connection used to get the domain is limited only a 
         /// partial set of the information can be extracted.
         /// </summary>
         /// <param name="domain">
@@ -586,10 +598,10 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetInfo(IntPtr domain, [Out] virDomainInfo info);
         /// <summary>
-        /// Retrieve the maximum amount of physical memory allocated to a domain.
+        /// Retrieve the maximum amount of physical memory allocated to a domain. 
         /// If domain is NULL, then this get the amount of memory reserved to Domain0 i.e. the domain where the application runs.
         /// </summary>
         /// <param name="domain">
@@ -598,11 +610,11 @@ namespace LibvirtBindings
         /// <returns>
         /// the memory size in kilobytes or 0 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern ulong virDomainGetMaxMemory(IntPtr domain);
         /// <summary>
-        /// Provides the maximum number of virtual CPUs supported for the guest VM.
-        /// If the guest is inactive, this is basically the same as virConnectGetMaxVcpus.
+        /// Provides the maximum number of virtual CPUs supported for the guest VM. 
+        /// If the guest is inactive, this is basically the same as virConnectGetMaxVcpus. 
         /// If the guest is running this will reflect the maximum number of virtual CPUs the guest was booted with.
         /// </summary>
         /// <param name="domain">
@@ -611,7 +623,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The maximum of virtual CPU or -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetMaxVcpus(IntPtr domain);
         /// <summary>
         /// Get the public name for that domain.
@@ -622,8 +634,8 @@ namespace LibvirtBindings
         /// <returns>
         /// Pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the domain object.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virDomainGetName(IntPtr domain);
         /// <summary>
         /// Get the type of domain operation system.
@@ -634,8 +646,8 @@ namespace LibvirtBindings
         /// <returns>
         /// The new string or NULL in case of error, the string must be freed by the caller.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virDomainGetOSType(IntPtr domain);
 
         // TODO virDomainGetSchedulerParameters
@@ -656,7 +668,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="System.Int32"/>-1 in case of error, 0 in case of success.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetUUID(IntPtr domain, [Out] char[] uuid);
         /// <summary>
         /// Get the UUID for a domain as string. For more information about UUID see RFC4122.
@@ -670,7 +682,7 @@ namespace LibvirtBindings
         /// <returns>
         /// -1 in case of error, 0 in case of success.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainGetUUIDString(IntPtr domain, [Out] IntPtr buf);
 
         // TODO virDomainGetVcpus
@@ -687,14 +699,14 @@ namespace LibvirtBindings
         /// <returns>
         /// A 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virDomainGetXMLDesc(IntPtr domain, int flags);
         /// <summary>
-        /// This function returns network interface stats for interfaces attached to the domain.
-        /// The path parameter is the name of the network interface. Domains may have more than one network interface.
-        /// To get stats for each you should make multiple calls to this function.
-        /// Individual fields within the stats structure may be returned as -1,
+        /// This function returns network interface stats for interfaces attached to the domain. 
+        /// The path parameter is the name of the network interface. Domains may have more than one network interface. 
+        /// To get stats for each you should make multiple calls to this function. 
+        /// Individual fields within the stats structure may be returned as -1, 
         /// which indicates that the hypervisor does not support that particular statistic.
         /// </summary>
         /// <param name="dom">
@@ -712,7 +724,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success or -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainInterfaceStats(IntPtr dom, string path, virDomainInterfaceStatsStruct stats, int size);
         /// <summary>
         /// Determine if the domain is currently running.
@@ -723,7 +735,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 1 if running, 0 if inactive, -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainIsActive(IntPtr dom);
 
         /// <summary>
@@ -735,12 +747,12 @@ namespace LibvirtBindings
         /// <returns>
         /// 1 if persistent, 0 if transient, -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainIsPersistent(IntPtr dom);
 
         /// <summary>
         /// Try to find a domain based on the hypervisor ID number.
-        /// Note that this won't work for inactive domains which have an ID of -1,
+        /// Note that this won't work for inactive domains which have an ID of -1, 
         /// in that case a lookup based on the Name or UUId need to be done instead.
         /// </summary>
         /// <param name="conn">
@@ -752,7 +764,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainLookupByID(IntPtr conn, int id);
 
         /// <summary>
@@ -767,7 +779,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainLookupByName(IntPtr conn, string name);
 
         /// <summary>
@@ -782,7 +794,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainLookupByUUID(IntPtr conn, char[] uuid);
 
         /// <summary>
@@ -797,7 +809,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A new domain object or NULL in case of failure. If the domain cannot be found, then VIR_ERR_NO_DOMAIN error is raised.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virDomainLookupByUUIDString(IntPtr conn, string uuidstr);
 
         // TODO virDomainMemoryPeek
@@ -811,7 +823,7 @@ namespace LibvirtBindings
         // TODO virDomainMemoryStats
 
         /// <summary>
-        /// Reboot a domain, the domain object is still usable there after but the domain OS is being stopped for a restart.
+        /// Reboot a domain, the domain object is still usable there after but the domain OS is being stopped for a restart. 
         /// Note that the guest OS may ignore the request.
         /// </summary>
         /// <param name="domain">
@@ -823,15 +835,15 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainReboot(IntPtr domain, uint flags);
 
         /// <summary>
-        /// Increment the reference count on the domain. For each additional call to this method,
-        /// there shall be a corresponding call to virDomainFree to release the reference count,
-        /// once the caller no longer needs the reference to this object.
-        /// This method is typically useful for applications where multiple threads are using a connection,
-        /// and it is required that the connection remain open until all threads have finished using it. ie,
+        /// Increment the reference count on the domain. For each additional call to this method, 
+        /// there shall be a corresponding call to virDomainFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
         /// each new thread using a domain would increment the reference count.
         /// </summary>
         /// <param name="domain">
@@ -840,7 +852,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainRef(IntPtr domain);
 
         /// <summary>
@@ -855,11 +867,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainRestore(IntPtr conn, string from);
 
         /// <summary>
-        /// Resume a suspended domain, the process is restarted from the state where it was frozen by calling virSuspendDomain().
+        /// Resume a suspended domain, the process is restarted from the state where it was frozen by calling virSuspendDomain(). 
         /// This function may requires privileged access
         /// </summary>
         /// <param name="domain">
@@ -868,11 +880,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainResume(IntPtr domain);
 
         /// <summary>
-        /// This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful,
+        /// This method will suspend a domain and save its memory contents to a file on disk. After the call, if successful, 
         /// the domain is not listed as running anymore (this may be a problem). Use virDomainRestore() to restore a domain after saving.
         /// </summary>
         /// <param name="domain">
@@ -884,7 +896,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSave(IntPtr domain, string to);
 
         /// <summary>
@@ -899,12 +911,12 @@ namespace LibvirtBindings
         /// <returns>
         /// -1 in case of error, 0 in case of success.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSetAutostart(IntPtr domain, int autostart);
 
         /// <summary>
-        /// Dynamically change the maximum amount of physical memory allocated to a domain.
-        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e.
+        /// Dynamically change the maximum amount of physical memory allocated to a domain. 
+        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
         /// the domain where the application runs. This function requires privileged access to the hypervisor.
         /// </summary>
         /// <param name="domain">
@@ -916,12 +928,12 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSetMaxMemory(IntPtr domain, ulong memory);
 
         /// <summary>
-        /// Dynamically change the target amount of physical memory allocated to a domain.
-        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e.
+        /// Dynamically change the target amount of physical memory allocated to a domain. 
+        /// If domain is NULL, then this change the amount of memory reserved to Domain0 i.e. 
         /// the domain where the application runs. This function may requires privileged access to the hypervisor.
         /// </summary>
         /// <param name="domain">
@@ -933,14 +945,14 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSetMemory(IntPtr domain, ulong memory);
 
         // TODO virDomainSetSchedulerParameters
 
         /// <summary>
-        /// Dynamically change the number of virtual CPUs used by the domain.
-        /// Note that this call may fail if the underlying virtualization hypervisor does not support it
+        /// Dynamically change the number of virtual CPUs used by the domain. 
+        /// Note that this call may fail if the underlying virtualization hypervisor does not support it 
         /// or if growing the number is arbitrary limited. This function requires privileged access to the hypervisor.
         /// </summary>
         /// <param name="domain">
@@ -952,12 +964,12 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSetVcpus(IntPtr domain, uint nvcpus);
 
         /// <summary>
-        /// Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped.
-        /// Note that the guest OS may ignore the request.
+        /// Shutdown a domain, the domain object is still usable there after but the domain OS is being stopped. 
+        /// Note that the guest OS may ignore the request. 
         /// </summary>
         /// <param name="domain">
         /// A <see cref="IntPtr"/>domain object.
@@ -965,12 +977,12 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainShutdown(IntPtr domain);
 
         /// <summary>
-        /// Suspends an active domain, the process is frozen without further access to CPU resources and I/O
-        /// but the memory used by the domain at the hypervisor level will stay allocated.
+        /// Suspends an active domain, the process is frozen without further access to CPU resources and I/O 
+        /// but the memory used by the domain at the hypervisor level will stay allocated. 
         /// Use virDomainResume() to reactivate the domain. This function may requires privileged access.
         /// </summary>
         /// <param name="domain">
@@ -979,7 +991,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainSuspend(IntPtr domain);
 
         /// <summary>
@@ -991,7 +1003,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virDomainUndefine(IntPtr domain);
         #endregion
 
@@ -1006,7 +1018,7 @@ namespace LibvirtBindings
         ///<param name="addTimeout">the virEventAddTimeoutFunc which will be called (a delegate)</param>
         ///<param name="updateTimeout">the virEventUpdateTimeoutFunc which will be called (a delegate)</param>
         ///<param name="removeTimeout">the virEventRemoveTimeoutFunc which will be called (a delegate)</param>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern void virEventRegisterImpl([MarshalAs(UnmanagedType.FunctionPtr)]virEventAddHandleFunc addHandle,
                                                        [MarshalAs(UnmanagedType.FunctionPtr)]virEventUpdateHandleFunc updateHandle,
                                                        [MarshalAs(UnmanagedType.FunctionPtr)]virEventRemoveHandleFunc removeHandle,
@@ -1017,8 +1029,8 @@ namespace LibvirtBindings
 
         #region Library
         /// <summary>
-        /// Provides two information back, @libVer is the version of the library while @typeVer will be the version of the hypervisor
-        /// type @type against which the library was compiled. If @type is NULL, "Xen" is assumed,
+        /// Provides two information back, @libVer is the version of the library while @typeVer will be the version of the hypervisor 
+        /// type @type against which the library was compiled. If @type is NULL, "Xen" is assumed, 
         /// if @type is unknown or not available, an error code will be returned and @typeVer will be 0.
         /// </summary>
         /// <param name="libVer">
@@ -1033,16 +1045,16 @@ namespace LibvirtBindings
         /// <returns>
         /// -1 in case of failure, 0 otherwise, and values for @libVer and @typeVer have the format major * 1,000,000 + minor * 1,000 + release.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virGetVersion([Out] out ulong libVer, [In] string type, [Out] out ulong typeVer);
         /// <summary>
-        /// Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid
+        /// Initialize the library. It's better to call this routine at startup in multithreaded applications to avoid 
         /// potential race when initializing the library.
         /// </summary>
         /// <returns>
         /// 0 in case of success, -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virInitialize();
         #endregion
 
@@ -1075,11 +1087,11 @@ namespace LibvirtBindings
         // TODO virInterfaceUndefine
 
         /// <summary>
-        /// Increment the reference count on the network. For each additional call to this method,
-        /// there shall be a corresponding call to virNetworkFree to release the reference count,
-        /// once the caller no longer needs the reference to this object.
-        /// This method is typically useful for applications where multiple threads are using a connection,
-        /// and it is required that the connection remain open until all threads have finished using it. ie,
+        /// Increment the reference count on the network. For each additional call to this method, 
+        /// there shall be a corresponding call to virNetworkFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
         /// each new thread using a network would increment the reference count.
         /// </summary>
         /// <param name="network">
@@ -1088,7 +1100,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkRef(IntPtr network);
 
         // TODO virNetworkSetAutostart
@@ -1116,8 +1128,8 @@ namespace LibvirtBindings
         /// <param name="dev">pointer to the node device</param>
         /// <param name="flags">flags for XML generation (unused, pass 0)</param>
         /// <returns>the XML document, or NULL on error</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virNodeDeviceGetXMLDesc(IntPtr dev, uint flags);
 
         // TODO virNodeDeviceListCaps
@@ -1128,7 +1140,7 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="name">unique device name</param>
         /// <returns>a virNodeDevicePtr if found, NULL otherwise.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNodeDeviceLookupByName(IntPtr conn, string name);
         // TODO virNodeDeviceNumOfCaps
 
@@ -1141,7 +1153,7 @@ namespace LibvirtBindings
         // TODO virNodeGetCellsFreeMemory
 
         /// <summary>
-        /// Provides the free memory available on the Node Note: most libvirt APIs provide memory sizes in kilobytes,
+        /// Provides the free memory available on the Node Note: most libvirt APIs provide memory sizes in kilobytes, 
         /// but in this function the returned value is in bytes. Divide by 1024 as necessary.
         /// </summary>
         /// <param name="conn">
@@ -1150,7 +1162,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The available free memory in bytes or 0 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern ulong virNodeGetFreeMemory(IntPtr conn);
         /// <summary>
         /// Extract hardware information about the node.
@@ -1164,7 +1176,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success and -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNodeGetInfo(IntPtr h, [Out] virNodeInfo info);
 
         // TODO virNodeGetSecurityModel
@@ -1191,7 +1203,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The number of node devices found or -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNodeListDevices(IntPtr conn, string cap, IntPtr names, int maxnames, uint flags);
         /// <summary>
         /// Collect the list of node devices, and store their names in @names.
@@ -1225,7 +1237,7 @@ namespace LibvirtBindings
             return count;
         }
         /// <summary>
-        /// Provides the number of node devices. If the optional 'cap' argument is non-NULL,
+        /// Provides the number of node devices. If the optional 'cap' argument is non-NULL, 
         /// then the count will be restricted to devices with the specified capability.
         /// </summary>
         /// <param name="conn">
@@ -1240,7 +1252,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The number of node devices or -1 in case of error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNodeNumOfDevices(IntPtr conn, string cap, uint flags);
         #endregion
 
@@ -1291,7 +1303,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 upon failure
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolBuild(IntPtr pool, virStoragePoolBuildFlags flags);
 
         /// <summary>
@@ -1306,11 +1318,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 if it could not be started.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolCreate(IntPtr pool, uint flags);
 
         /// <summary>
-        /// Create a new storage based on its XML description. The pool is not persistent,
+        /// Create a new storage based on its XML description. The pool is not persistent, 
         /// so its definition will disappear when it is destroyed, or if the host is restarted
         /// </summary>
         /// <param name="conn">
@@ -1325,11 +1337,11 @@ namespace LibvirtBindings
         /// <returns>
         /// A virStoragePoolPtr object, or NULL if creation failed.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolCreateXML(IntPtr conn, string xmlDesc, uint flags);
 
         /// <summary>
-        /// Define a new inactive storage pool based on its XML description. The pool is persistent,
+        /// Define a new inactive storage pool based on its XML description. The pool is persistent, 
         /// until explicitly undefined.
         /// </summary>
         /// <param name="conn">
@@ -1344,7 +1356,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A virStoragePoolPtr object, or NULL if creation failed.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolDefineXML(IntPtr conn, string xml, uint flags);
 
         /// <summary>
@@ -1359,13 +1371,13 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 if it could not be obliterate.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolDelete(IntPtr pool, virStoragePoolDeleteFlags flags);
 
         /// <summary>
-        /// Destroy an active storage pool. This will deactivate the pool on the host,
-        /// but keep any persistent config associated with it.
-        /// If it has a persistent config it can later be restarted with virStoragePoolCreate().
+        /// Destroy an active storage pool. This will deactivate the pool on the host, 
+        /// but keep any persistent config associated with it. 
+        /// If it has a persistent config it can later be restarted with virStoragePoolCreate(). 
         /// This does not free the associated virStoragePoolPtr object.
         /// </summary>
         /// <param name="pool">
@@ -1374,7 +1386,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 if it could not be destroyed.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolDestroy(IntPtr pool);
 
         /// <summary>
@@ -1386,7 +1398,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 if it could not be free'd.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolFree(IntPtr pool);
 
         /// <summary>
@@ -1399,11 +1411,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, -1 on failure
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolGetAutostart(IntPtr pool, out int autotart);
 
         /// <summary>
-        /// Provides the connection pointer associated with a storage pool. The reference counter on the connection is not increased by this call.
+        /// Provides the connection pointer associated with a storage pool. The reference counter on the connection is not increased by this call. 
         /// WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the pool object together.
         /// </summary>
         /// <param name="pool">
@@ -1412,7 +1424,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>the virConnectPtr or NULL in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolGetConnect(IntPtr pool);
 
         /// <summary>
@@ -1427,7 +1439,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolGetInfo(IntPtr pool, ref virStoragePoolInfo info);
 
         /// <summary>
@@ -1439,8 +1451,8 @@ namespace LibvirtBindings
         /// <returns>
         /// The name of the pool, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStoragePoolGetName(IntPtr pool);
 
         /// <summary>
@@ -1455,7 +1467,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on error
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolGetUUID(IntPtr pool, [Out] char[] uuid);
 
         /// <summary>
@@ -1470,7 +1482,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virStoragePoolGetUUIDString(IntPtr pool, [Out] char[] uuid);
 
         ///<summary>
@@ -1487,7 +1499,7 @@ namespace LibvirtBindings
             return new string(uuidArray);
         }
         /// <summary>
-        /// Fetch an XML document describing all aspects of the storage pool.
+        /// Fetch an XML document describing all aspects of the storage pool. 
         /// This is suitable for later feeding back into the virStoragePoolCreateXML method.
         /// </summary>
         /// <param name="pool">
@@ -1499,8 +1511,8 @@ namespace LibvirtBindings
         /// <returns>
         /// A XML document, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStoragePoolGetXMLDesc(IntPtr pool, virDomainXMLFlags flags);
 
         /// <summary>
@@ -1512,7 +1524,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 1 if running, 0 if inactive, -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolIsActive(IntPtr pool);
 
         /// <summary>
@@ -1524,7 +1536,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 1 if persistent, 0 if transient, -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolIsPersistent(IntPtr pool);
 
         /// <summary>
@@ -1542,7 +1554,7 @@ namespace LibvirtBindings
         /// <returns>
         /// The number of names fetched, or -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virStoragePoolListVolumes(IntPtr pool, IntPtr names, int maxnames);
         /// <summary>
         /// Fetch list of storage volume names, limiting to at most maxnames.
@@ -1580,7 +1592,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>virStoragePoolPtr object, or NULL if no matching pool is found.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolLookupByName(IntPtr conn, string name);
 
         /// <summary>
@@ -1595,7 +1607,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A virStoragePoolPtr object, or NULL if no matching pool is found
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolLookupByUUID(IntPtr conn, char[] uuid);
 
         /// <summary>
@@ -1610,7 +1622,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolLookupByUUIDString(IntPtr conn, string uuidstr);
 
         /// <summary>
@@ -1622,7 +1634,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>object, or NULL if no matching pool is found.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStoragePoolLookupByVolume(IntPtr vol);
 
         /// <summary>
@@ -1634,15 +1646,15 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="System.Int32"/>the number of storage pools, or -1 on failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolNumOfVolumes(IntPtr pool);
 
         /// <summary>
-        /// Increment the reference count on the pool. For each additional call to this method,
-        /// there shall be a corresponding call to virStoragePoolFree to release the reference count,
-        /// once the caller no longer needs the reference to this object.
-        /// This method is typically useful for applications where multiple threads are using a connection,
-        /// and it is required that the connection remain open until all threads have finished using it. ie,
+        /// Increment the reference count on the pool. For each additional call to this method, 
+        /// there shall be a corresponding call to virStoragePoolFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
         /// each new thread using a pool would increment the reference count.
         /// </summary>
         /// <param name="pool">
@@ -1651,11 +1663,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 in case of success, -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolRef(IntPtr pool);
 
         /// <summary>
-        /// Request that the pool refresh its list of volumes. This may involve communicating with a remote server,
+        /// Request that the pool refresh its list of volumes. This may involve communicating with a remote server, 
         /// and/or initializing new devices at the OS layer.
         /// </summary>
         /// <param name="pool">
@@ -1682,7 +1694,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, -1 on failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolSetAutostart(IntPtr pool, int autostart);
 
         /// <summary>
@@ -1694,7 +1706,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, -1 on failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStoragePoolUndefine(IntPtr pool);
         #endregion
 
@@ -1715,11 +1727,11 @@ namespace LibvirtBindings
         /// <returns>
         /// The storage volume, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolCreateXML(IntPtr pool, string xmldesc, uint flags);
 
         /// <summary>
-        /// Create a storage volume in the parent pool, using the 'clonevol' volume as input.
+        /// Create a storage volume in the parent pool, using the 'clonevol' volume as input. 
         /// Information for the new volume (name, perms) are passed via a typical volume XML description.
         /// </summary>
         /// <param name="pool">
@@ -1737,7 +1749,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>the storage volume, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolCreateXMLFrom(IntPtr pool, string xmldesc, IntPtr clonevol, uint flags);
 
         /// <summary>
@@ -1752,7 +1764,7 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStorageVolDelete(IntPtr vol, uint flags);
 
         /// <summary>
@@ -1764,13 +1776,13 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStorageVolFree(IntPtr vol);
 
         /// <summary>
-        /// Provides the connection pointer associated with a storage volume.
-        /// The reference counter on the connection is not increased by this call.
-        /// WARNING: When writing libvirt bindings in other languages, do not use this function.
+        /// Provides the connection pointer associated with a storage volume. 
+        /// The reference counter on the connection is not increased by this call. 
+        /// WARNING: When writing libvirt bindings in other languages, do not use this function. 
         /// Instead, store the connection and the volume object together.
         /// </summary>
         /// <param name="vol">
@@ -1779,7 +1791,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolGetConnect(IntPtr vol);
 
         /// <summary>
@@ -1794,11 +1806,11 @@ namespace LibvirtBindings
         /// <returns>
         /// 0 on success, or -1 on failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStorageVolGetInfo(IntPtr vol, ref virStorageVolInfo info);
 
         /// <summary>
-        /// Fetch the storage volume key.
+        /// Fetch the storage volume key. 
         /// This is globally unique, so the same volume will have the same key no matter what host it is accessed from
         /// </summary>
         /// <param name="vol">
@@ -1807,8 +1819,8 @@ namespace LibvirtBindings
         /// <returns>
         /// The volume key, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStorageVolGetKey(IntPtr vol);
 
         /// <summary>
@@ -1820,14 +1832,14 @@ namespace LibvirtBindings
         /// <returns>
         /// The volume name, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStorageVolGetName(IntPtr vol);
 
         /// <summary>
-        /// Fetch the storage volume path.
-        /// Depending on the pool configuration this is either persistent across hosts,
-        /// or dynamically assigned at pool startup.
+        /// Fetch the storage volume path. 
+        /// Depending on the pool configuration this is either persistent across hosts, 
+        /// or dynamically assigned at pool startup. 
         /// Consult pool documentation for information on getting the persistent naming.
         /// </summary>
         /// <param name="vol">
@@ -1836,8 +1848,8 @@ namespace LibvirtBindings
         /// <returns>
         /// The storage volume path, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStorageVolGetPath(IntPtr vol);
 
         /// <summary>
@@ -1852,8 +1864,8 @@ namespace LibvirtBindings
         /// <returns>
         /// The XML document, or NULL on error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virStorageVolGetXMLDesc(IntPtr vol, uint flags);
 
         /// <summary>
@@ -1868,7 +1880,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolLookupByKey(IntPtr conn, string key);
 
         /// <summary>
@@ -1883,7 +1895,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolLookupByName(IntPtr pool, string name);
 
         /// <summary>
@@ -1898,15 +1910,15 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="IntPtr"/>storage volume, or NULL if not found / error.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virStorageVolLookupByPath(IntPtr conn, string path);
 
         /// <summary>
-        /// Increment the reference count on the vol. For each additional call to this method,
-        /// there shall be a corresponding call to virStorageVolFree to release the reference count,
-        /// once the caller no longer needs the reference to this object.
-        /// This method is typically useful for applications where multiple threads are using a connection,
-        /// and it is required that the connection remain open until all threads have finished using it. ie,
+        /// Increment the reference count on the vol. For each additional call to this method, 
+        /// there shall be a corresponding call to virStorageVolFree to release the reference count, 
+        /// once the caller no longer needs the reference to this object. 
+        /// This method is typically useful for applications where multiple threads are using a connection, 
+        /// and it is required that the connection remain open until all threads have finished using it. ie, 
         /// each new thread using a vol would increment the reference count.
         /// </summary>
         /// <param name="vol">
@@ -1915,7 +1927,7 @@ namespace LibvirtBindings
         /// <returns>
         /// A <see cref="System.Int32"/>0 in case of success, -1 in case of failure.
         /// </returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virStorageVolRef(IntPtr vol);
 
         #endregion
@@ -1983,7 +1995,7 @@ namespace LibvirtBindings
         /// </summary>
         /// <param name="network">pointer to a defined network</param>
         /// <returns>0 in case of success, -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkCreate(IntPtr network);
         /// <summary>
         /// Create and start a new virtual network, based on an XML description similar to the one returned by virNetworkGetXMLDesc()
@@ -1991,7 +2003,7 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="xmlDesc">an XML description of the network</param>
         /// <returns>a new network object or NULL in case of failure</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNetworkCreateXML(IntPtr conn, string xmlDesc);
         /// <summary>
         /// Define a network, but does not create it
@@ -1999,21 +2011,21 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="xmlDesc">the XML description for the network, preferably in UTF-8</param>
         /// <returns>NULL in case of error, a pointer to the network otherwise</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNetworkDefineXML(IntPtr conn, string xmlDesc);
         /// <summary>
         /// Destroy the network object. The running instance is shutdown if not down already and all resources used by it are given back to the hypervisor. This does not free the associated virNetworkPtr object. This function may require privileged access
         /// </summary>
         /// <param name="network">a network object</param>
         /// <returns>0 in case of success and -1 in case of failure.</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkDestroy(IntPtr network);
         /// <summary>
         /// Free the network object. The running instance is kept alive. The data structure is freed and should not be used thereafter.
         /// </summary>
         /// <param name="network">a network object</param>
         /// <returns>0 in case of success and -1 in case of failure</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkFree(IntPtr network);
         /// <summary>
         /// Provides a boolean value indicating whether the network configured to be automatically started when the host machine boots.
@@ -2021,30 +2033,30 @@ namespace LibvirtBindings
         /// <param name="network">a network object</param>
         /// <param name="autostart">the value returned</param>
         /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkGetAutostart(IntPtr network, int autostart);
         /// <summary>
         /// Provides a bridge interface name to which a domain may connect a network interface in order to join the network.
         /// </summary>
         /// <param name="network">a network object</param>
         /// <returns>a 0 terminated interface name, or NULL in case of error. the caller must free() the returned value</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virNetworkGetBridgeName(IntPtr network);
         /// <summary>
         /// Provides the connection pointer associated with a network. The reference counter on the connection is not increased by this call. WARNING: When writing libvirt bindings in other languages, do not use this function. Instead, store the connection and the network object together
         /// </summary>
         /// <param name="network">pointer to a network</param>
         /// <returns>the virConnectPtr or NULL in case of failure</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNetworkGetConnect(IntPtr network);
         /// <summary>
         /// Get the public name for that network
         /// </summary>
         /// <param name="network">a network object</param>
         /// <returns>a pointer to the name or NULL, the string need not be deallocated its lifetime will be the same as the network object</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virNetworkGetName(IntPtr network);
         /// <summary>
         /// Get the UUID for a network as string
@@ -2052,7 +2064,7 @@ namespace LibvirtBindings
         /// <param name="network">a network object</param>
         /// <param name="uuid">string of the uuid</param>
         /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         private static extern int virNetworkGetUUIDString(IntPtr network, [Out] char[] uuid);
 
         ///<summary>
@@ -2072,22 +2084,22 @@ namespace LibvirtBindings
         /// <param name="network">a network object</param>
         /// <param name="flags">an OR'ed set of extraction flags, not used yet</param>
         /// <returns>a 0 terminated UTF-8 encoded XML instance, or NULL in case of error. the caller must free() the returned value</returns>
-        [DllImport("libvirt-0.dll")]
-        [return: MarshalAs(UnmanagedType.AnsiBStr)]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
+        [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StringWithoutNativeCleanUpMarshaler))]
         public static extern string virNetworkGetXMLDesc(IntPtr network, int flags);
         /// <summary>
         /// Determine if the network is currently running
         /// </summary>
         /// <param name="network">pointer to the network object</param>
         /// <returns>1 if running, 0 if inactive, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkIsActive(IntPtr network);
         /// <summary>
         /// Determine if the network has a persistent configuration which means it will still exist after shutting down
         /// </summary>
         /// <param name="network">pointer to the network object</param>
         /// <returns>x1 if persistent, 0 if transient, -1 on error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkIsPersistent(IntPtr network);
         /// <summary>
         /// Try to lookup a network on the given hypervisor based on its name.
@@ -2095,7 +2107,7 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="name">name for the network</param>
         /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNetworkLookupByName(IntPtr conn, string name);
         /// <summary>
         /// Try to lookup a network on the given hypervisor based on its UUID
@@ -2103,7 +2115,7 @@ namespace LibvirtBindings
         /// <param name="conn">pointer to the hypervisor connection</param>
         /// <param name="uuidstr">the string UUID for the network</param>
         /// <returns>a new network object or NULL in case of failure. If the network cannot be found, then VIR_ERR_NO_NETWORK error is raised</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern IntPtr virNetworkLookupByUUIDString(IntPtr conn, string uuidstr);
         /// <summary>
         /// Configure the network to be automatically started when the host machine boots
@@ -2111,20 +2123,20 @@ namespace LibvirtBindings
         /// <param name="network">a network object</param>
         /// <param name="autostart">whether the network should be automatically started 0 or 1</param>
         /// <returns>-1 in case of error, 0 in case of success</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkSetAutostart(IntPtr network, int autostart);
         /// <summary>
         /// Undefine a network but does not stop it if it is running
         /// </summary>
         /// <param name="network">pointer to a defined network</param>
         /// <returns>0 in case of success, -1 in case of error</returns>
-        [DllImport("libvirt-0.dll")]
+        [DllImport(LibvirtDllImportName, CallingConvention=CallingConvention.Cdecl)]
         public static extern int virNetworkUndefine(IntPtr network);
 
         #endregion
 
         #region Helpers
-
+        
         private static string[] ptrToStringArray(IntPtr stringPtr, int stringCount)
         {
             string[] members = new string[stringCount];
diff --git a/LibvirtBindings.csproj b/LibvirtBindings.csproj
deleted file mode 100644
index 7ddaa82..0000000
--- a/LibvirtBindings.csproj
+++ /dev/null
@@ -1,63 +0,0 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{61AF36A9-0D6C-4E02-9B9B-39908463A82E}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>LibvirtBindings</RootNamespace>
-    <AssemblyName>LibvirtBindings</AssemblyName>
-    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <TargetFrameworkProfile />
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <DocumentationFile>bin\Debug\LibvirtBindings.XML</DocumentationFile>
-    <PlatformTarget>AnyCPU</PlatformTarget>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Libvirt.cs" />
-    <Compile Include="LibvirtError.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="COPYING.LIB" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="COPYING.txt" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>
\ No newline at end of file
diff --git a/LibvirtBindings.sln b/LibvirtBindings.sln
deleted file mode 100644
index cfa349c..0000000
--- a/LibvirtBindings.sln
+++ /dev/null
@@ -1,20 +0,0 @@
-﻿
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibvirtBindings", "LibvirtBindings.csproj", "{61AF36A9-0D6C-4E02-9B9B-39908463A82E}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Any CPU = Debug|Any CPU
-		Release|Any CPU = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{61AF36A9-0D6C-4E02-9B9B-39908463A82E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{61AF36A9-0D6C-4E02-9B9B-39908463A82E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{61AF36A9-0D6C-4E02-9B9B-39908463A82E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{61AF36A9-0D6C-4E02-9B9B-39908463A82E}.Release|Any CPU.Build.0 = Release|Any CPU
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal
diff --git a/LibvirtError.cs b/LibvirtError.cs
index a018624..eaab401 100644
--- a/LibvirtError.cs
+++ b/LibvirtError.cs
@@ -564,7 +564,7 @@ namespace LibvirtBindings
             public int int2;
             /// <summary>
             /// Network if available, deprecated see note above.
-            /// </summary>
+            /// </summary>     
             [MarshalAs(UnmanagedType.SysInt)]
             public IntPtr net;
         }
@@ -574,7 +574,7 @@ namespace LibvirtBindings
         // virConnGetLastError - Deprecated
 
         /// <summary>
-        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently.
+        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
         /// Reset the last error caught on that connection.
         /// </summary>
         /// <param name="conn">
@@ -584,7 +584,7 @@ namespace LibvirtBindings
         public static extern void virConnResetLastError(IntPtr conn);
 
         /// <summary>
-        /// Set a connection error handling function, if @handler is NULL it will reset to default
+        /// Set a connection error handling function, if @handler is NULL it will reset to default 
         /// which is to pass error back to the global library handler.
         /// </summary>
         /// <param name="conn">
@@ -600,8 +600,8 @@ namespace LibvirtBindings
         public static extern void virConnSetErrorFunc(IntPtr conn, IntPtr userData, [MarshalAs(UnmanagedType.FunctionPtr)]virErrorFunc handler);
 
         /// <summary>
-        /// Copy the content of the last error caught at the library level.
-        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently.
+        /// Copy the content of the last error caught at the library level. 
+        /// The error object is kept in thread local storage, so separate threads can safely access this concurrently. 
         /// One will need to free the result with virResetError().
         /// </summary>
         /// <param name="to">
@@ -632,7 +632,7 @@ namespace LibvirtBindings
         public static extern void virFreeError(virError err); // Does not work, anybody know why?
 
         /// <summary>
-        /// Provide a pointer to the last error caught at the library level.
+        /// Provide a pointer to the last error caught at the library level. 
         /// The error object is kept in thread local storage, so separate threads can safely access this concurrently.
         /// </summary>
         /// <returns>
@@ -651,7 +651,7 @@ namespace LibvirtBindings
         public static extern void virResetError(virError err);
 
         /// <summary>
-        /// Reset the last error caught at the library level. The error object is kept in thread local storage,
+        /// Reset the last error caught at the library level. The error object is kept in thread local storage, 
         /// so separate threads can safely access this concurrently, only resetting their own error object.
         /// </summary>
         [DllImport("libvirt-0.dll")]
@@ -661,14 +661,14 @@ namespace LibvirtBindings
         /// Save the last error into a new error object.
         /// </summary>
         /// <returns>
-        /// A <see cref="virError"/> pointer to the copied error or NULL if allocation failed.
+        /// A <see cref="virError"/> pointer to the copied error or NULL if allocation failed. 
         /// It is the caller's responsibility to free the error with virFreeError().
         /// </returns>
         [DllImport("libvirt-0.dll")]
         public static extern virError virSaveLastError();
 
         /// <summary>
-        /// Set a library global error handling function, if @handler is NULL, it will reset to default printing on stderr.
+        /// Set a library global error handling function, if @handler is NULL, it will reset to default printing on stderr. 
         /// The error raised there are those for which no handler at the connection level could caught.
         /// </summary>
         /// <param name="userData">
diff --git a/LibvirtTypes.cs b/LibvirtTypes.cs
index 2b9c11f..de307dc 100644
--- a/LibvirtTypes.cs
+++ b/LibvirtTypes.cs
@@ -7,6 +7,8 @@
  */
 
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using System.Runtime.InteropServices;
 
 namespace LibvirtBindings
@@ -90,7 +92,7 @@ namespace LibvirtBindings
     ///<param name="ncred">number of virConnectCredential in cred</param>
     ///<param name="cbdata">user data passed to callback</param>
     [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-    public delegate int virConnectAuthCallbackPtr([In, Out] IntPtr cred, uint ncred, IntPtr cbdata);
+    public delegate int virConnectAuthCallback(IntPtr cred, uint ncred, IntPtr cbdata);
     #endregion
 
     #region structs
@@ -171,28 +173,71 @@ namespace LibvirtBindings
         /// <summary>
         /// List of supported virConnectCredentialType values, should be a IntPtr to an int array or to a virConnectCredentialType array
         /// </summary>
-        public IntPtr credtypes;
+        private IntPtr credtypes;
         ///<summary>
         /// Number of virConnectCredentialType in credtypes
         ///</summary>
-        [MarshalAs(UnmanagedType.I4)]
-        public int ncredtype;
+        [MarshalAs(UnmanagedType.U4)]
+        private uint ncredtype;
         ///<summary>
         /// Callback used to collect credentials, a virConnectAuthCallback delegate in bindings
         ///</summary>
         [MarshalAs(UnmanagedType.FunctionPtr)]
-        public virConnectAuthCallbackPtr cb;
+        public virConnectAuthCallback cb;
+        ///<summary>
+        /// Data transported with callback, should be a IntPtr on what you want
+        ///</summary>
+        private IntPtr cbdataPtr;
         ///<summary>
         /// Data transported with callback, should be a IntPtr on what you want
         ///</summary>
-        public IntPtr cbdata;
+        public Object cbdata
+        {
+            get
+            {
+                return Marshal.PtrToStructure(cbdataPtr, typeof(Object));
+            }
+            set
+            {
+                cbdataPtr = Marshal.AllocHGlobal(Marshal.SizeOf(value));
+                Marshal.StructureToPtr(value, cbdataPtr, false);
+            }
+        }
+        /// <summary>
+        /// List of supported virConnectCredentialType values
+        /// </summary>
+        public virConnectCredentialType[] CredTypes
+        {
+            get
+            {
+                int[] intCredTypes = new int[ncredtype];
+                Marshal.Copy(credtypes, intCredTypes, 0, (int)ncredtype);
+				virConnectCredentialType[] result = new virConnectCredentialType[ncredtype];
+				for (int i=0; i< intCredTypes.Length; i++)
+				{
+					result[i] = (virConnectCredentialType)i;
+				}
+                return result;
+            }
+            set
+            {
+                ncredtype = (uint)value.Length;
+                credtypes = Marshal.AllocHGlobal(value.Length * sizeof(int));
+				int[] vals = new int[value.Length];
+				for (int i=0; i<value.Length; i++)
+				{
+					vals[i] = (int)value[i];
+				}
+                Marshal.Copy(vals, 0, credtypes, (int)ncredtype);
+            }
+        }
     }
 
     ///<summary>
     /// Credential structure
     ///</summary>
-    [StructLayout(LayoutKind.Sequential, Pack = 4)]
-    public struct virConnectCredential
+    [StructLayout(LayoutKind.Sequential)]
+    public class virConnectCredential
     {
         ///<summary>
         /// One of virConnectCredentialType constants
@@ -202,27 +247,72 @@ namespace LibvirtBindings
         ///<summary>
         /// Prompt to show to user
         ///</summary>
-        [MarshalAs(UnmanagedType.LPStr)]
-        public string prompt;
+        //[MarshalAs(UnmanagedType.LPStr)]
+        private IntPtr prompt;
         ///<summary>
         /// Additional challenge to show
         ///</summary>
-        [MarshalAs(UnmanagedType.LPStr)]
-        public string challenge;
+        //[MarshalAs(UnmanagedType.LPStr)]
+        private IntPtr challenge;
         ///<summary>
         /// Optional default result
         ///</summary>
-        [MarshalAs(UnmanagedType.LPStr)]
-        public string defresult;
+        //[MarshalAs(UnmanagedType.LPStr)]
+        private IntPtr defresult;
         ///<summary>
         /// Result to be filled with user response (or defresult). An IntPtr to a marshalled allocated string
         ///</summary>
-        public IntPtr result;
+        //[MarshalAs(UnmanagedType.LPStr)]
+        private IntPtr result;
         ///<summary>
         /// Length of the result
         ///</summary>
         [MarshalAs(UnmanagedType.U4)]
         public uint resultlen;
+        ///<summary>
+        /// Prompt to show to user
+        ///</summary>
+        public string Prompt
+        {
+            get
+            {
+                return Marshal.PtrToStringAnsi(prompt);
+            }
+        }
+        ///<summary>
+        /// Additional challenge to show
+        ///</summary>
+        public string Challenge
+        {
+            get
+            {
+                return Marshal.PtrToStringAnsi(challenge);
+            }
+        }
+        ///<summary>
+        /// Optional default result
+        ///</summary>
+        public string Defresult
+        {
+            get
+            {
+                return Marshal.PtrToStringAnsi(defresult);
+            }
+        }
+        ///<summary>
+        /// Result to be filled with user response (or defresult).
+        ///</summary>
+        public string Result
+        {
+            get
+            {
+                return Marshal.PtrToStringAnsi(result);
+            }
+            set
+            {
+                result = libVirt.StrDup(Marshal.StringToHGlobalAnsi(value));
+            }
+        }
     }
 
     ///<summary>
@@ -402,22 +492,22 @@ namespace LibvirtBindings
         /// </summary>
         VIR_DOMAIN_MEMORY_STAT_SWAP_IN = 0,
         /// <summary>
-        /// * Page faults occur when a process makes a valid access to virtual memory * that is not available. When servicing the page fault, if disk IO is * required, it is considered a major fault. If not, it is a minor fault. * These are expressed as the number of faults that have occurred. *
+        /// * Page faults occur when a process makes a valid access to virtual memory * that is not available. When servicing the page fault, if disk IO is * required, it is considered a major fault. If not, it is a minor fault. * These are expressed as the number of faults that have occurred. * 
         /// </summary>
         VIR_DOMAIN_MEMORY_STAT_SWAP_OUT = 1,
 #pragma warning disable 1591
         VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT = 2,
 #pragma warning restore 1591
         /// <summary>
-        /// * The amount of memory left completely unused by the system. Memory that * is available but used for reclaimable caches should NOT be reported as * free. This value is expressed in kB. *
+        /// * The amount of memory left completely unused by the system. Memory that * is available but used for reclaimable caches should NOT be reported as * free. This value is expressed in kB. * 
         /// </summary>
         VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT = 3,
         /// <summary>
-        /// * The total amount of usable memory as seen by the domain. This value * may be less than the amount of memory assigned to the domain if a * balloon driver is in use or if the guest OS does not initialize all * assigned pages. This value is expressed in kB. *
+        /// * The total amount of usable memory as seen by the domain. This value * may be less than the amount of memory assigned to the domain if a * balloon driver is in use or if the guest OS does not initialize all * assigned pages. This value is expressed in kB. * 
         /// </summary>
         VIR_DOMAIN_MEMORY_STAT_UNUSED = 4,
         /// <summary>
-        /// * The number of statistics supported by this version of the interface. * To add new statistics, add them to the enum and increase this value. *
+        /// * The number of statistics supported by this version of the interface. * To add new statistics, add them to the enum and increase this value. * 
         /// </summary>
         VIR_DOMAIN_MEMORY_STAT_AVAILABLE = 5,
 #pragma warning disable 1591
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1cbfb29..0000000
--- a/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-﻿using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// Les informations générales relatives à un assembly dépendent de
-// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
-// associées à un assembly.
-[assembly: AssemblyTitle("LibvirtBindings")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Microsoft")]
-[assembly: AssemblyProduct("LibvirtBindings")]
-[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
-// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
-// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
-[assembly: ComVisible(false)]
-
-// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
-[assembly: Guid("16f4aacb-8e02-4c2d-902f-e83f0a7c0570")]
-
-// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
-//
-//      Version principale
-//      Version secondaire
-//      Numéro de build
-//      Révision
-//
-// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
-// en utilisant '*', comme indiqué ci-dessous :
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-- 
1.7.2.3.msysgit.0

