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 MarshalByRefObj ect (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 4723
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
CreateInstanceA ndUnwrap. 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_s 53... 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 MarshalByRefObj ect (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$******** ******@TK2MSFTN GP11.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 CreateInstanceA ndUnwrap. 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_s 53... 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 MarshalByRefObj ect (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 <string>
#include <iostream>
#include <stdarg.h>
|
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 usable in C#) whose WriteSample function takes a byte* parameter
Do I need to marshal data? I thought I did, so I ran into alot of issues with converting the byte to a string and then, in the MC++ DLL, marshalling that to an IntPtr via...
|
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 method parameter.
if i use this direct approach, i get the error:
Message: Cannot marshal 'parameter #1': Internal limitation: structure is
too complex or too large."
is there a 64k limit on marshalling structures? what workarounds are there...
|
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: An unhandled exception of
type 'System.EntryPointNotFoundException'.
This is confusing b/c if the entry point was not found, I would think I'd
get an unresolved symbol error during linking. Furthermore, I can
successfully pass void, int *, and...
|
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 and Web.config files:
<messaging>
<maxRequestLength>-1</maxRequestLength>
</messaging>
The largest file I've downloaded is 70 meg and that's more than plenty for
me. However, I'm finding that on upload, if I attempt to upload greater than
| |
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 C++/CLI code by using C++
Interop )
But unfortunately I have only one day experience in C++/CLI so all my
attempts are failing.
|
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 to transfer it to intptr :
|
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:
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\
cstringt.h(875): error C2664: 'PtrToStringChars' : cannot convert parameter 1
from 'unsigned char *' to 'const System::String __gc *'
The code segemnt is:
|
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 reading the 1st 5 lines or so when
there is about 30 lines of data.
I also tried using the Process.BeginOutputReadlin and a
DataReceivedEvntHandler to gather output but I also only get about 5 lines of
the data.
There seems to be a buffer size...
|
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 really
need to do the same thing in C#.
How can I put the structure in memory to be able to call SendMessage
and get the expected results in the structure.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| | |