Hello,
We've recently started using RDNZL for integration between an internal application written in ACL 7.0 and a CAD system using a .Net-based extension-layer in the latter; using .Net Remoting for communicating between the two systems. We've found that RDNZL works robustly, reliably and is very easy to use. Thank you very much for creating it.
I have a question with regards to the action of the CAST operator: Currently, when CAST'ing from one .Net class to another, the type of the container is destructively updated; and there doesn't seem to be any way of copying a container so that a reference to the same object but with another type can be created. That is, I'd like to do something like
(cast foo "SomeType")) (setq bar (copy-container foo)) (cast bar "SomeOtherType"))
without the last operating also setting the type of FOO to SomeOtherType [1]
Is there some idiom that would work like this that I've missed? If not, I guess the functionality would have to be added at the C++ level, which I haven't really looked at yet. Any pointers would be appreciated.
Iver Odin Kvello iok@selvaag.no
[1] The actual situation that came up was this: We have a remote object - actually a transparent proxy - of an interface-type WALL, and we need to get a reference to its lease. However, to to this we must cast the object to MarshalByRefObject, and if we use CAST to get this, it is impossible to CAST back to the original interface type. We did find a workaround: using System.Runtime.Remoting.RemotingServices.GetRealProxy, another copy of the transparent proxy is easily obtained, and that can be cast to a MBRO instead. But a copy/cast-operator would have been nicer.
Hi,
On Wed, 25 Apr 2007 09:33:39 +0200, "Iver Odin Kvello" iok@selvaag.no wrote:
We've recently started using RDNZL for integration between an internal application written in ACL 7.0 and a CAD system using a .Net-based extension-layer in the latter; using .Net Remoting for communicating between the two systems. We've found that RDNZL works robustly, reliably and is very easy to use. Thank you very much for creating it.
Thanks, that's good to hear.
I have a question with regards to the action of the CAST operator: Currently, when CAST'ing from one .Net class to another, the type of the container is destructively updated; and there doesn't seem to be any way of copying a container so that a reference to the same object but with another type can be created. That is, I'd like to do something like
(cast foo "SomeType")) (setq bar (copy-container foo)) (cast bar "SomeOtherType"))
without the last operating also setting the type of FOO to SomeOtherType [1]
Is there some idiom that would work like this that I've missed?
I first have to admit that I myself am pretty busy with other stuff at the moment and that I haven't used RDNZL in earnest for quite some time, so bear with me if I'm talking nonsense... :)
The answer IIRC is that what you want is currently not supported.
If not, I guess the functionality would have to be added at the C++ level, which I haven't really looked at yet. Any pointers would be appreciated.
Yes, you'd have to do that at in the C++ code, i.e. create a "copy" operation in the DotNetContainer class which copies an existing container and returns (a pointer to) the copy. And export that operation so that you can use it from Lisp. And then make it available to Lisp via the FFI. I /think/ that shouldn't be too hard and shouldn't result in any GC problems.
Of course, if you do that it'd be nice if you could send your modifications back to the list so I can include it in a future release:
The actual situation that came up was this: We have a remote object
- actually a transparent proxy - of an interface-type WALL, and we
need to get a reference to its lease. However, to to this we must cast the object to MarshalByRefObject, and if we use CAST to get this, it is impossible to CAST back to the original interface type.
I'm probably too dense at the moment, but /why/ can't you just cast back?
Cheers, Edi.
Yes, you'd have to do that at in the C++ code, i.e. create a "copy" operation in the DotNetContainer class which copies an existing container and returns (a pointer to) the copy. And export that operation so that you can use it from Lisp. And then make it available to Lisp via the FFI. I /think/ that shouldn't be too hard and shouldn't result in any GC problems.
Thank you, I'll have a look.
Also: I just realised that there is a very simple additional workaround: One could just load in an assembly with a class with a static method
public static Object Copy(Object o) { return o; }
That worked too; but I've installed a C++ setup anyway to try to understand things better.
Of course, if you do that it'd be nice if you could send your modifications back to the list so I can include it in a future release
We will.
and if we use CAST to get this, it is impossible to CAST back to the original interface type.
I'm probably too dense at the moment, but /why/ can't you just cast back?
I don't really know why exactly, but the error given is
Error: .NET error (System.InvalidCastException): Object must implement IConvertible.
Regards, Iver Odin Kvello iok@selvaag.no
On Thu, 26 Apr 2007 17:11:32 +0200, "Iver Odin Kvello" iok@selvaag.no wrote:
I don't really know why exactly, but the error given is
Error: .NET error (System.InvalidCastException): Object must implement IConvertible.
Strange. Does that only happen for certain objects or always if you try to cast something back and forth?
Thanks, Edi.
Strange. Does that only happen for certain objects or always if you
try to cast something back and forth?
Only for certain objects, but I can reproduce it fairly easily:
RDNZL-USER(5): (import-types "System" "Net.WebClient") NIL RDNZL-USER(6): (setf w (new "System.Net.WebClient")) #<RDNZL::CONTAINER System.Net.WebClient #xda75ac8> RDNZL-USER(7): (cast w "System.Object") Error: .NET error (System.InvalidCastException): Object must implement IConvertible. [condition type: RDNZL-ERROR]
I didn't think of it as an issue; I just assumed it was some sort of .Net restriction.
Iver Odin Kvello iok@selvaag.no
On Thu, 26 Apr 2007 17:43:29 +0200, "Iver Odin Kvello" iok@selvaag.no wrote:
Only for certain objects, but I can reproduce it fairly easily:
RDNZL-USER(5): (import-types "System" "Net.WebClient") NIL RDNZL-USER(6): (setf w (new "System.Net.WebClient")) #<RDNZL::CONTAINER System.Net.WebClient #xda75ac8> RDNZL-USER(7): (cast w "System.Object") Error: .NET error (System.InvalidCastException): Object must implement IConvertible. [condition type: RDNZL-ERROR]
I didn't think of it as an issue; I just assumed it was some sort of .Net restriction.
Yes, it is - I checked the .NET documentation. Thanks for the info.