473,513 Members | 3,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(2nd Attempt) Passing Objects

I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the
object is created successfully and the objects method can be called after
loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it
can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it deal
with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to
the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it
lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if need
be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading
object, method is called inside the object and works fine. Next I try to
return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject, or
one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it
was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan


Jul 19 '05 #1
6 1881
When you say......... DOMAIN...... do you mean... application process
space or a true domain ?

Assuming you mean... application process space...... as building a DOMAIN
on the fly could be an interesting challenge but not very practical for many
purposes....... applications must know where the objects are... and the
references that are created are just pointers to the process space..... If
your loader pulls the object up... it probably is in it's own process
space...... and not sitting out somewhere for other applications to
reference.....

While this hasn't offered alot of information on how to fix your
situation...... assuming that you do create a means to create all of the
objects .... OUT OF PROCESS.... to run in their own spaces.... (for
whatever reasons)... the jump across process boundries..... isn't real
nice... and it does cost performance.... and there are certain types of
objects that WILL NOT cross boundries.... (no matter what you do... that
is by design)

While I don't want to pry too far into your objects... or the over all
design... maybe I should ask... How are you going to UNLOAD IT ? Is this
going to run somewhere like COM+ services ? How will you kill off just ONE
instance ? Let's say you can.... which one of the 10 loaded do you kill
off ? Does it have any other processes that it points to ? what happens
to the process count of those objects ? Or do you increment the process
count... everytime you pass the reference to the object... and decrement
it accordingly ? If the components your loader creates is ActiveX style...
how do you manage the references when the loader gets created by different
applications?

I'm sure you have all the bases covered in your design..... and have built
error trapping to handle all the situations....... like what was a valid
reference in an application... just turn invalid because you destroyed the
object it was referencing.....

"Bryan Martin" <sp**@ahwayside.com> wrote in message news:us5eCoiWDHA.652@TK
2MSFTNGP10.phx.gbl...
I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the
object is created successfully and the objects method can be called after
loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it deal with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to
the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if need
be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading
object, method is called inside the object and works fine. Next I try to
return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject, or one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it
was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan

Jul 19 '05 #2
Jon
Normally you pass a common interface or a common abstract class between the app domains.

Do you plan to pass the whole new type back, and have the parent use reflection to access the properties?

"Bryan Martin" <sp**@ahwayside.com> wrote in message news:us*************@TK2MSFTNGP10.phx.gbl...
I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the
object is created successfully and the objects method can be called after
loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it
can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it deal
with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to
the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it
lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if need
be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading
object, method is called inside the object and works fine. Next I try to
return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject, or
one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it
was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan

Jul 19 '05 #3
By domain I do mean application domain. The purpose behind this is to load
the object(s) dynamically. Because I need to be able to unload the
object(s) is why I choose the seperate domain loading in the first place.
To my knowledge the only way to unload a assembly that has been loaded
dynamically is to unload the actual domain instead (which for all intense
and purposes has worked thus far). All dynamically loaded assemblies must
inherit there respected interface. By looping though all types inside the
assembly I can make sure they do infact adhear to this rule prior to
loading. You are correct in that because the object is initiated in its own
domain I cannot access the object from the parent class. This is what
prompted the question. Because everything must implement the given
interface I plan to use the parent class for marshaling everything though to
the loaded objects. And using the parent class with good error handling for
all marshalling should allow for a one stop solution to most of the
questions about dealing with certain circumstances.

Bryan

"Steve S" <be*********@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP10.phx.gbl...
When you say......... DOMAIN...... do you mean... application process
space or a true domain ?

Assuming you mean... application process space...... as building a DOMAIN on the fly could be an interesting challenge but not very practical for many purposes....... applications must know where the objects are... and the
references that are created are just pointers to the process space..... If your loader pulls the object up... it probably is in it's own process
space...... and not sitting out somewhere for other applications to
reference.....

While this hasn't offered alot of information on how to fix your
situation...... assuming that you do create a means to create all of the
objects .... OUT OF PROCESS.... to run in their own spaces.... (for
whatever reasons)... the jump across process boundries..... isn't real
nice... and it does cost performance.... and there are certain types of
objects that WILL NOT cross boundries.... (no matter what you do... that
is by design)

While I don't want to pry too far into your objects... or the over all
design... maybe I should ask... How are you going to UNLOAD IT ? Is this going to run somewhere like COM+ services ? How will you kill off just ONE instance ? Let's say you can.... which one of the 10 loaded do you kill off ? Does it have any other processes that it points to ? what happens
to the process count of those objects ? Or do you increment the process
count... everytime you pass the reference to the object... and decrement
it accordingly ? If the components your loader creates is ActiveX style... how do you manage the references when the loader gets created by different
applications?

I'm sure you have all the bases covered in your design..... and have built
error trapping to handle all the situations....... like what was a valid
reference in an application... just turn invalid because you destroyed the object it was referencing.....

"Bryan Martin" <sp**@ahwayside.com> wrote in message news:us5eCoiWDHA.652@TK 2MSFTNGP10.phx.gbl...
I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the object is created successfully and the objects method can be called after loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it
can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it

deal
with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it
lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if

need be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading object, method is called inside the object and works fine. Next I try to return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject,

or
one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan


Jul 19 '05 #4
My load function looks something like this

Function Load(ByVal AssemblyName as string, ExpectedType as Type)as object

After loading the assembly I loop though the types finding all that equal
the expectedtype.

I have also passed a class of expected type to the function and set it to
the newly created object. This allows me to use the class to call the
methods successfully inside this domain but when it gets passed back I still
get bombed.

Thanks for your time.
Bryan


"Jon" <Jo*@martinsound.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Normally you pass a common interface or a common abstract class between the app domains.
Do you plan to pass the whole new type back, and have the parent use reflection to access the properties?
"Bryan Martin" <sp**@ahwayside.com> wrote in message

news:us*************@TK2MSFTNGP10.phx.gbl...
I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the object is created successfully and the objects method can be called after loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it deal with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if need be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading object, method is called inside the object and works fine. Next I try to return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject, or one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan


Jul 19 '05 #5
Jon
Seach MSDN for "AppDomains and Dynamic Loading" C# sample.
I think it is very similar to what you are trying to accomplish.

"Bryan Martin" <sp**@ahwayside.com> wrote in message news:uI**************@tk2msftngp13.phx.gbl...
My load function looks something like this

Function Load(ByVal AssemblyName as string, ExpectedType as Type)as object

After loading the assembly I loop though the types finding all that equal
the expectedtype.

I have also passed a class of expected type to the function and set it to
the newly created object. This allows me to use the class to call the
methods successfully inside this domain but when it gets passed back I still
get bombed.

Thanks for your time.
Bryan


"Jon" <Jo*@martinsound.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
Normally you pass a common interface or a common abstract class between

the app domains.

Do you plan to pass the whole new type back, and have the parent use

reflection to access the properties?

"Bryan Martin" <sp**@ahwayside.com> wrote in message

news:us*************@TK2MSFTNGP10.phx.gbl...
I have a object that is created in a seperate domain which needs to be
passed back to the parent class. Because this object is created in a
seperate domain if I try to pass the object back to the parent class
(different domain) I receive an error about "File Not Found". I know the object is created successfully and the objects method can be called after loading the object however upon passing it back to the calling class it
exploades. I do not want to proxy everything though the loader class so it can be versitile enough to load other objects with different methods. I
would much rather pass the loaded object back to the parent and have it deal with what class/methods.

The original post from Thursday, July 31, 2003
Scenario is to load assembly in its own domain and return objects back to the parent for later use. Plug-in style

ParentProgram
Creates a new class named PluginLoader and calls sub loadassembly

PluginLoader
LoadAssembly creates a new appdomain and new class PluginProcessor. Next it lets pluginprocessor load the actual objects needed from the assembly
because I need this to run in its own appdomain so I can unload it if need be.

PluginProcessor
Loads the assembly and gathers the required objects. Right after loading object, method is called inside the object and works fine. Next I try to return this object back to PluginLoader. PluginLoader attempts to call
method inside object and fails with "File or assembly name LoadedObject, or one of its dependencies, was not found."

What am I missing? How do I get the object back to the parent? I know it was found due to being able to call the methods inside PluginProcessor
successfully.

Bryan



Jul 19 '05 #6
Ohhhhh I owe you big time. This was exactly what the problem was. After
correcting this it works like a charm.

Solution was:
The class that was being loaded did not inherit MarshalByRefObject. Where
in the heck were you a week ago when this problem began?

Again I cant thank you enough Michell. *blushing*
"Bryan Martin" <sp**@ahwayside.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
I'll check and let you know. Thanks for your time.

"Jon" <Jo*@martinsound.com> wrote in message
news:OP**************@TK2MSFTNGP12.phx.gbl...
Seach MSDN for "AppDomains and Dynamic Loading" C# sample.
I think it is very similar to what you are trying to accomplish.

"Bryan Martin" <sp**@ahwayside.com> wrote in message news:uI**************@tk2msftngp13.phx.gbl...
My load function looks something like this

Function Load(ByVal AssemblyName as string, ExpectedType as Type)as object
After loading the assembly I loop though the types finding all that equal the expectedtype.

I have also passed a class of expected type to the function and set it to the newly created object. This allows me to use the class to call the
methods successfully inside this domain but when it gets passed back I still get bombed.

Thanks for your time.
Bryan


"Jon" <Jo*@martinsound.com> wrote in message
news:eN**************@TK2MSFTNGP11.phx.gbl...
> Normally you pass a common interface or a common abstract class between the app domains.
>
> Do you plan to pass the whole new type back, and have the parent use
reflection to access the properties?
>
> "Bryan Martin" <sp**@ahwayside.com> wrote in message
news:us*************@TK2MSFTNGP10.phx.gbl...
> > I have a object that is created in a seperate domain which needs to be
> > passed back to the parent class. Because this object is created
in
a > > seperate domain if I try to pass the object back to the parent
class > > (different domain) I receive an error about "File Not Found". I
know the
> > object is created successfully and the objects method can be called after
> > loading the object however upon passing it back to the calling class it
> > exploades. I do not want to proxy everything though the loader class so it
> > can be versitile enough to load other objects with different methods. I > > would much rather pass the loaded object back to the parent and
have
it deal
> > with what class/methods.
> >
> > The original post from Thursday, July 31, 2003
> > Scenario is to load assembly in its own domain and return objects back to
> > the parent for later use. Plug-in style
> >
> > ParentProgram
> > Creates a new class named PluginLoader and calls sub loadassembly
> >
> > PluginLoader
> > LoadAssembly creates a new appdomain and new class
PluginProcessor. Next it
> > lets pluginprocessor load the actual objects needed from the

assembly > > because I need this to run in its own appdomain so I can unload it if need
> > be.
> >
> > PluginProcessor
> > Loads the assembly and gathers the required objects. Right after
loading
> > object, method is called inside the object and works fine. Next I try to
> > return this object back to PluginLoader. PluginLoader attempts to call > > method inside object and fails with "File or assembly name LoadedObject, or
> > one of its dependencies, was not found."
> >
> > What am I missing? How do I get the object back to the parent? I know it
> > was found due to being able to call the methods inside PluginProcessor > > successfully.
> >
> > Bryan
> >
> >
> >
> >
>
>



Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14910
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
1
4607
by: Qin Chen | last post by:
I will present very long code, hope someone will read it all, and teach me something like tom_usenet. This question comes to me when i read <<Think in C++>> 2nd, chapter 10 , name control, section "Static initialization dependency". There is a example to show how to solve the prolem involved with a technique first poineered by Jerry Schwarz...
9
4766
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I am using vector class(STL), the compiler does not allow me to do this. I do realize there is a pitfall in this approach(size of arrays not...
6
1451
by: Bryan Martin | last post by:
I have a object that is created in a seperate domain which needs to be passed back to the parent class. Because this object is created in a seperate domain if I try to pass the object back to the parent class (different domain) I receive an error about "File Not Found". I know the object is created successfully and the objects method can be...
0
1086
by: sklett | last post by:
I'm having a really hard time with wrapping an unmanaged class with a managed class, then calling that managed class from my C# code. I will show you the three pieces, then explain: -------- Unmanaged C++ code --------- bool FindFileItem(PCSTR filename, IVSSItem& founditem); // note that founditem is a REFERENCE -------- Managed...
6
3242
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A query-string flag is used to indicate to the page whether it should instantiate a new instance of the object or access an existing instance from the...
28
1908
by: VK | last post by:
A while ago I wrote a "Vector data type" script using DOM interface to select.options. That was a (beautiful) mind game :-) rather than a practical thing to use. Here is another attempt open for criticism, this time dead serious. I really need an effective Vector emulator for a project (as much effective as something not implemeted in...
9
3771
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting techniques are not feasible) The question is; Given that I have a Person object with a private set for id. What is the recommended approac in passing...
4
2805
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all objects should be passed by reference using the ref keyword generally speaking because as the writer of code you are conveying your intentions that an...
0
7270
marktang
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...
0
7178
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...
0
7397
Oralloy
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. ...
0
7563
jinu1996
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...
1
7125
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...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.