I have a class Cliente in project ventas and FormaPago in project ERP. I have Association of Cliente and FormaPago. When I try recover a cliente, A mistake is produced: your code try recover Ventas.formapago and it is Incorrect, the correct is ERP.formapago. This error is produced in:
Public Function CreateObjectInstance(ByVal baseObject As CPersistentObject) As CPersistentObject
If AssemblyPath Is Nothing OrElse AssemblyPath = String.Empty Then
Dim aa As [Assembly]
aa = aa.GetAssembly(baseObject.GetType)
'Just use the namespace property of the type instead of mucking around - danmayer 24May04
**********here****************
*****************************
Return Activator.CreateInstance(aa.GetType(baseObject.GetType.Namespace & "." & Name))
**********here****************
*****************************
Else
Dim objHdl As ObjectHandle
If ClassNameSpace = String.Empty Then
objHdl = Activator.CreateInstanceFrom(AssemblyPath, Name)
Else
objHdl = Activator.CreateInstanceFrom(AssemblyPath, ClassNameSpace & "." & Name)
End If
Return CType(objHdl.Unwrap(), CPersistentObject)
End If
End Function
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a class Cliente in project ventas and FormaPago in project ERP. I have Association of Cliente and FormaPago. When I try recover a cliente, A mistake is produced: your code try recover Ventas.formapago and it is Incorrect, the correct is ERP.formapago. This error is produced in:
Public Function CreateObjectInstance(ByVal baseObject As CPersistentObject) As CPersistentObject
If AssemblyPath Is Nothing OrElse AssemblyPath = String.Empty Then
Dim aa As [Assembly]
aa = aa.GetAssembly(baseObject.GetType)
'Just use the namespace property of the type instead of mucking around - danmayer 24May04
**********here****************
*****************************
Return Activator.CreateInstance(aa.GetType(baseObject.GetType.Namespace & "." & Name))
**********here****************
*****************************
Else
Dim objHdl As ObjectHandle
If ClassNameSpace = String.Empty Then
objHdl = Activator.CreateInstanceFrom(AssemblyPath, Name)
Else
objHdl = Activator.CreateInstanceFrom(AssemblyPath, ClassNameSpace & "." & Name)
End If
Return CType(objHdl.Unwrap(), CPersistentObject)
End If
End Function
When objects are joined the assumption is made that the objects are in the same namespace, unless a specific namespace and assembly is provided.
You need to provide more information in the XML mappings to help the framework use the correct assembly and namespace when instantiating a new object.
In the <class ... /> mapping add the attributes
assemblypath="..."
namespace="..."
as required to help find the class. In you example, you would have
<class name="FormaPago" AssemblyPath="..." Namespace="ERP" ... >
...
</class>
- Richard.
Its suggestion is the correct one
Thank you.