It is known that one cannot pass arguments as ref or out in a
marshal-by-reference class. My problem is that I have a C DLL (and C#
wrapper) that I need to isolate in an AppDomain and then I need to interact
with many objects in that DLL and wrapper by reference. (So the classes
inherit from MBRO.) While my app is running, I need to obtain info from
objects in the 2nd app domain frequently/speedily and I need update the GUI;
and I need to pass user actions back to the DLL. I also need to handle
events across the AppDomain boundary. All this sounds fairly standard, I
guess (I'm new to remoting.)
However, the C# wrapper has a lot of methods that use 'out' parameters, and
I can't change this (might as well rewrite the whole app from scratch). So,
my question is, How can I isolate this set of objects in an AppDomain
without throwing all that code away? The methods with ref and out parameters
could be wholly 'bounded' or contained within the new AppDomain. In other
words, these methods are not needed in regard to communicating across the
AppDomain boundary, but are only needed for objects within the new AppDomain
to interact with each other. Any suggestions on how to do this?
On a different but related point, I read in a post from 2001 the following:
" Fields of App-Domain-bound objects must be accessed through accessors.
so for any objects derived from MarshalByRefObject (as is your TreeNode)
you must provide put/get methods (for your color member)."
If I understand that correctly, it means that implementing Properties in
place of certain methods the C# wrapper currently uses for returning values
would help. But that doesn't solve my main ref/out param issue, but it is
interesting. Anyone care to point me to more info on either/both of these
topics?
Dave 2 4624
Hum, complex topic. What you should do IMO, if the objects you need are
created and consumed in your second AppDomain, is to create a proxy object
that you create from your first AppDomain in your second AppDomain using
CreateInstanceAndUnwrap. If this object inherit from MBR, you can then use
it to call methods that will in fact execute in the second application
domain, and you can, in these methods create your objects or get back the
objects from the out and ref parameters of your C dll. It's then just a
matter of getting the value you want back, and put them in a MBV back to
your first AppDomain to prevent any more marshalling.
This is the only way I could figure to get good encapsulation and prevent a
few nifty remoting tricks such as viral dll loading across appdomains :)
--
Sebastien Lambla http://thetechnologist.is-a-geek.com/blog/
"Mountain Bikn' Guy" <vc@attbi.com> a écrit dans le message de news:
cBRpb.77282$275.206628@attbi_s53... It is known that one cannot pass arguments as ref or out in a marshal-by-reference class. My problem is that I have a C DLL (and C# wrapper) that I need to isolate in an AppDomain and then I need to
interact with many objects in that DLL and wrapper by reference. (So the classes inherit from MBRO.) While my app is running, I need to obtain info from objects in the 2nd app domain frequently/speedily and I need update the
GUI; and I need to pass user actions back to the DLL. I also need to handle events across the AppDomain boundary. All this sounds fairly standard, I guess (I'm new to remoting.)
However, the C# wrapper has a lot of methods that use 'out' parameters,
and I can't change this (might as well rewrite the whole app from scratch).
So, my question is, How can I isolate this set of objects in an AppDomain without throwing all that code away? The methods with ref and out
parameters could be wholly 'bounded' or contained within the new AppDomain. In other words, these methods are not needed in regard to communicating across the AppDomain boundary, but are only needed for objects within the new
AppDomain to interact with each other. Any suggestions on how to do this?
On a different but related point, I read in a post from 2001 the
following: " Fields of App-Domain-bound objects must be accessed through accessors. so for any objects derived from MarshalByRefObject (as is your TreeNode) you must provide put/get methods (for your color member)."
If I understand that correctly, it means that implementing Properties in place of certain methods the C# wrapper currently uses for returning
values would help. But that doesn't solve my main ref/out param issue, but it is interesting. Anyone care to point me to more info on either/both of these topics?
Dave
Thank you for your reply. This is a very helpful suggestion and I'll
remember it when I need to use it. For now, I have decided not to use a 2nd
AppDomain.
"Sebastien Lambla" <se**************@6sens.com> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl... Hum, complex topic. What you should do IMO, if the objects you need are created and consumed in your second AppDomain, is to create a proxy object that you create from your first AppDomain in your second AppDomain using CreateInstanceAndUnwrap. If this object inherit from MBR, you can then use it to call methods that will in fact execute in the second application domain, and you can, in these methods create your objects or get back the objects from the out and ref parameters of your C dll. It's then just a matter of getting the value you want back, and put them in a MBV back to your first AppDomain to prevent any more marshalling.
This is the only way I could figure to get good encapsulation and prevent
a few nifty remoting tricks such as viral dll loading across appdomains :)
-- Sebastien Lambla http://thetechnologist.is-a-geek.com/blog/
"Mountain Bikn' Guy" <vc@attbi.com> a écrit dans le message de news: cBRpb.77282$275.206628@attbi_s53... It is known that one cannot pass arguments as ref or out in a marshal-by-reference class. My problem is that I have a C DLL (and C# wrapper) that I need to isolate in an AppDomain and then I need to interact with many objects in that DLL and wrapper by reference. (So the classes inherit from MBRO.) While my app is running, I need to obtain info from objects in the 2nd app domain frequently/speedily and I need update the GUI; and I need to pass user actions back to the DLL. I also need to handle events across the AppDomain boundary. All this sounds fairly standard, I guess (I'm new to remoting.)
However, the C# wrapper has a lot of methods that use 'out' parameters, and I can't change this (might as well rewrite the whole app from scratch). So, my question is, How can I isolate this set of objects in an AppDomain without throwing all that code away? The methods with ref and out parameters could be wholly 'bounded' or contained within the new AppDomain. In
other words, these methods are not needed in regard to communicating across
the AppDomain boundary, but are only needed for objects within the new AppDomain to interact with each other. Any suggestions on how to do this?
On a different but related point, I read in a post from 2001 the following: " Fields of App-Domain-bound objects must be accessed through accessors. so for any objects derived from MarshalByRefObject (as is your
TreeNode) you must provide put/get methods (for your color member)."
If I understand that correctly, it means that implementing Properties in place of certain methods the C# wrapper currently uses for returning values would help. But that doesn't solve my main ref/out param issue, but it
is interesting. Anyone care to point me to more info on either/both of
these topics?
Dave
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vijay |
last post by:
Hi all,
Im using
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20)
on 64bit linux server
im trying to compile following code
--------------------sam.cpp---------------------
#include...
|
by: wbaccay |
last post by:
I have a byte of binary data received from a NetworkStream (C# code) that I need to pass to the IWMWriter object in a DLL written in Managed extensions for C++ (since the Windows Media SDK is not...
|
by: Kirk Marple |
last post by:
i have a large C++ data structure that i'm trying to interop with... the
structure is 77400 bytes long. i have the structure defined in C#, so i was
trying to just use "ref <structure>" as the...
|
by: glutz7878 |
last post by:
I have no trouble passing __delegate ptrs to native C functions in DLLs,
however when attempting to pass the __delegate ptr to a native C++ function
in a DLL I get the following runtime exception:...
|
by: Joseph Geretz |
last post by:
I'm developing a Web Service using DIME to download and upload files from
and to an IIS server. In order to increase the download filesize to
unlimited, I have the following block in my App.config...
|
by: vladislavf |
last post by:
Hi All,
I need to pass array of strings from C++/CLI to unmanaged C++ function.
(The unmanaged API signatire is : int Combine(int NumOfInputFiles,
wchar_t **names) and I want to call it from...
|
by: shengmin.ruan |
last post by:
i got a struct like:
---------------------
public ref struct OutPacket{
int m_replyIndex;
List<MainInfo^>^ m_mainInfos;
};
---------------------
when i pass it to another process, i have...
|
by: Madhu_TN |
last post by:
Hi All,
I am new to this board. I am trying to create a Crystal Report viewer into a
VS C++ Dot NET 2003 app ( This uses both managed and unmanaged code).
I get the following compilation error:...
|
by: =?Utf-8?B?UHVjY2E=?= |
last post by:
Hi, I'm using VS 2005, ,.net 2 for C# windows application. I'm using Process
to run a C application and redirecting its standard output so I can read it
with StreamReader.ReadToEnd. It's only...
|
by: michelqa |
last post by:
Hi,
I already post a similar question last week without success.
Ok I want to get the current text selection in a RICHEDIT control..
This can be easily done in C++ with EM_EXGETSEL message. I...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| | |