473,748 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mixed-mode and "non-default" app domains

Is it at all possible to leverage mixed-mode assemblies from AppDomains
other than the default AppDomain? Is there any means at all of doing this?
Mixed-mode is incredibly convenient, but if I cannot load/unload/reload
extensions into my large and slow-to-load application during development
without restarting the process then the disadvantages may outweigh the
advantages.

I've got a mixed-mode program in which I create a new AppDomain and then use
CreateInstance( ) on a type from another assembly. That other assembly is
created by the C# compiler. Though written in C# the type being instanced
is itself derived from a mixed-mode class in yet another 3rd assembly.

I get a System.NullRefe renceException when the mixed-mode code runs in the
non-default app-domain.
Nov 17 '05 #1
8 3511
Hi Bern,

Thanks for posting in the community.

Currently I am consulting your problem to some dev members . We will reply
here with more information as soon as possible.
If you have any more concerns on it, please feel free to post here.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #2
Hi Bern,

From your description, I understand that you got a
System.NullRefe renceException when the C# type(derived from a mixed-mode
class) is being instanced in a non-default AppDomain, please correct me if
I misunderstand your issue.

Based on my knowledge, the System.NullRefe renceException will be thrown
while the code referenced to an invalid object, in your case, I think
perhaps it reference to a object which created in another AppDomain.

Something like the description from the Don Box's <<Essential.NET >> Chapter
8:
"
...
An object resides in exactly one AppDomain, as do values. Moreover, object
references must refer to objects in the same AppDomain. ...
Like objects, types reside in exactly one AppDomain. If two AppDomains need
to use a type, one must initialize and allocate the type once per
AppDomain. Additionally, one must load and initialize the type's module and
assembly once for each AppDomain the type is used in. Because each
AppDomain in a process maintains a separate copy of the type, each
AppDomain has its own private copy of the type's static fields.
...
"

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #3
I for the most part understand how pure assemblies work with app domains,
but I am not at all clear on what you can do with mixed-mode assemblies in a
multi-application domain situation. I'll elaborate a little on my
particular scenario in a moment, in case it's actually useful, but what I am
really in need of is a decent understanding of if/how one can leverage
mixed-mode assemblies from "non default" application domains. My great fear
is that the answer is "You cannot create/reference instances of types from
mixed-mode assemblies in non-default application domains and expect to do
anything useful with them". If that is true, the documentation would be
improved by spelling it out in both the AppDomain overviews and MC++
overviews.

If I have a mixed-mode type that uses IJW to leverage native code, can I
call/manipulate instances of such a type from an otherwise "clr pure"
assembly in a non-default application domain? If yes, then what about
inheritence? In other words can a type that is in a "non mixed-mode"
assembly, but which derives from a type in a mixed-mode assembly, function
properly in a non-default application domain? Yes or no?

The latter is my situation. From my mixed mode code in the default domain I
use AppDomain.Creat eInstance() to instantiate an object in another domain of
a type that inherits from a mixed-mode type. The constructor for that
derived type does get run and I can trace through it to it's point of death.
The first thing it does is call the mixed-mode base type's constructor and
it goes into it just fine. That base-type constructor goes out to native
code with IJW just fine. It is when it trys to come back into managed code
with IJW in the mixed-mode base type constructor that it goes boom. It
appears to go wrong inside of the thunk right there. My suspicion is that
the native-to-managed thunk contains an assumption that it is running in the
default application domain and that the default application domain is not
actually "current"; that the runtime let me make a direct call from a type
that was loaded in another domain to the base type that was ONLY loaded in
the default domain. If that is the case it seems as though the runtime and
compiler/linker could conspire to flag this at runtime rather than letting
you hang yourself. In other words, if those are the rules, could not the
compiler discover that the class being compiled had references to mixed-mode
assemblies (even though it was otherwise pure) and mark it as such so that
the runtime could throw a nice informative exception if someone tried to
instance the class in a non-default domain?

Can a mixed-mode assembly ever be "loaded" into a non-default application
domain? If the answer is no, then does that imply that types that are to be
instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?

-Bern

"Gary Chang" <v-******@online.m icrosoft.com> wrote in message
news:Yb******** ******@cpmsftng xa07.phx.gbl...
Hi Bern,

From your description, I understand that you got a
System.NullRefe renceException when the C# type(derived from a mixed-mode
class) is being instanced in a non-default AppDomain, please correct me if
I misunderstand your issue.

Based on my knowledge, the System.NullRefe renceException will be thrown
while the code referenced to an invalid object, in your case, I think
perhaps it reference to a object which created in another AppDomain.

Something like the description from the Don Box's <<Essential.NET >> Chapter 8:
"
..
An object resides in exactly one AppDomain, as do values. Moreover, object
references must refer to objects in the same AppDomain. ...
Like objects, types reside in exactly one AppDomain. If two AppDomains need to use a type, one must initialize and allocate the type once per
AppDomain. Additionally, one must load and initialize the type's module and assembly once for each AppDomain the type is used in. Because each
AppDomain in a process maintains a separate copy of the type, each
AppDomain has its own private copy of the type's static fields.
..
"

Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. --------------------

Nov 17 '05 #4
Hi Bern,

Thanks for your quickly reply!

It seems I misunderstood your concerns:
Can a mixed-mode assembly ever be "loaded" into a non-default application
domain? If the answer is no, then does that imply that types that are to be
instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?


Currently, we have submitted your questions to the vc dev team, and we will
reply you as soon as possible.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #5
Hello all (and Gary).

Just a reminder. I continue to watch this thread for the promised
response....

Bern McCarty
Bentley Systems, Inc.

"Gary Chang" <v-******@online.m icrosoft.com> wrote in message
news:Il******** ******@cpmsftng xa07.phx.gbl...
Hi Bern,

Thanks for your quickly reply!

It seems I misunderstood your concerns:
Can a mixed-mode assembly ever be "loaded" into a non-default application
domain? If the answer is no, then does that imply that types that are to

be instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?

Currently, we have submitted your questions to the vc dev team, and we

will reply you as soon as possible.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. --------------------

Nov 17 '05 #6
Hi Bern,

I put the post earlier but somehow it seemed to be missing in newsgroup.
Newsgroups: microsoft.publi c.dotnet.langua ges.vc
From: bh*****@online. microsoft.com (Bhavik Shah [MSFT])
Date: Wed, 18 Feb 2004 15:09:59 GMT
Subject: RE: Mixed-mode and "non-default" app domains

Hi Bern,

Sorry for the delay in responding to your question.

Is it possible for you to send a repro sample of what you are trying to do
and where it is failing? If yes, plese send it to me directly and you could
reach me at bh*****@online. microsoft.com (without the word "online").

Thanks,
Bhavik Shah
Microsoft Visual C++ Support
Would it be possible for you to send me small repro that shows what you are
trying?

Thanks,
Bhavik Shah
Microsoft Visual C++ Support

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Bern McCarty" <be**********@b entley.com>
References: <#u************ **@TK2MSFTNGP10 .phx.gbl> <Yb************ **@cpmsftngxa07 .phx.gbl>
<OS************ **@TK2MSFTNGP09 .phx.gbl>
<Il************ **@cpmsftngxa07 .phx.gbl>Subject: Re: Mixed-mode and "non-default" app domains
Date: Mon, 23 Feb 2004 09:33:24 -0500
Lines: 42
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uU************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vc
NNTP-Posting-Host: bsi-uu.bentley.com 64.90.224.40
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vc:33894
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vc

Hello all (and Gary).

Just a reminder. I continue to watch this thread for the promised
response... .

Bern McCarty
Bentley Systems, Inc.

"Gary Chang" <v-******@online.m icrosoft.com> wrote in message
news:Il****** ********@cpmsft ngxa07.phx.gbl. ..
Hi Bern,

Thanks for your quickly reply!

It seems I misunderstood your concerns:
>
Can a mixed-mode assembly ever be "loaded" into a non-default
application domain? If the answer is no, then does that imply that types that are

tobe
instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?
>

Currently, we have submitted your questions to the vc dev team, and we

will
reply you as soon as possible.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.
--------------------



Nov 17 '05 #7
Hello all (and Gary).

Just a reminder. I continue to watch this thread for the promised
response....

Bern McCarty
Bentley Systems, Inc.

"Gary Chang" <v-******@online.m icrosoft.com> wrote in message
news:Il******** ******@cpmsftng xa07.phx.gbl...
Hi Bern,

Thanks for your quickly reply!

It seems I misunderstood your concerns:
Can a mixed-mode assembly ever be "loaded" into a non-default application
domain? If the answer is no, then does that imply that types that are to

be instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?

Currently, we have submitted your questions to the vc dev team, and we

will reply you as soon as possible.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights. --------------------

Nov 17 '05 #8
Hi Bern,

I put the post earlier but somehow it seemed to be missing in newsgroup.
Newsgroups: microsoft.publi c.dotnet.langua ges.vc
From: bh*****@online. microsoft.com (Bhavik Shah [MSFT])
Date: Wed, 18 Feb 2004 15:09:59 GMT
Subject: RE: Mixed-mode and "non-default" app domains

Hi Bern,

Sorry for the delay in responding to your question.

Is it possible for you to send a repro sample of what you are trying to do
and where it is failing? If yes, plese send it to me directly and you could
reach me at bh*****@online. microsoft.com (without the word "online").

Thanks,
Bhavik Shah
Microsoft Visual C++ Support
Would it be possible for you to send me small repro that shows what you are
trying?

Thanks,
Bhavik Shah
Microsoft Visual C++ Support

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Bern McCarty" <be**********@b entley.com>
References: <#u************ **@TK2MSFTNGP10 .phx.gbl> <Yb************ **@cpmsftngxa07 .phx.gbl>
<OS************ **@TK2MSFTNGP09 .phx.gbl>
<Il************ **@cpmsftngxa07 .phx.gbl>Subject: Re: Mixed-mode and "non-default" app domains
Date: Mon, 23 Feb 2004 09:33:24 -0500
Lines: 42
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uU************ **@TK2MSFTNGP10 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.vc
NNTP-Posting-Host: bsi-uu.bentley.com 64.90.224.40
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vc:33894
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.vc

Hello all (and Gary).

Just a reminder. I continue to watch this thread for the promised
response... .

Bern McCarty
Bentley Systems, Inc.

"Gary Chang" <v-******@online.m icrosoft.com> wrote in message
news:Il****** ********@cpmsft ngxa07.phx.gbl. ..
Hi Bern,

Thanks for your quickly reply!

It seems I misunderstood your concerns:
>
Can a mixed-mode assembly ever be "loaded" into a non-default
application domain? If the answer is no, then does that imply that types that are

tobe
instantiated in a non-default domain cannot directly use types from
mixed-mode assemblies at all?
>

Currently, we have submitted your questions to the vc dev team, and we

will
reply you as soon as possible.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.
--------------------



Nov 17 '05 #9

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

Similar topics

220
19114
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
11
2791
by: csomberg | last post by:
SQL 2000 I thought I would throw this out there for some feedback from others. I'd like to know if you feel using MS auto-increment field is a good solution these days or should one grow their own ? Thanks, Me.
117
11876
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
239
10264
by: Eigenvector | last post by:
My question is more generic, but it involves what I consider ANSI standard C and portability. I happen to be a system admin for multiple platforms and as such a lot of the applications that my users request are a part of the OpenSource community. Many if not most of those applications strongly require the presence of the GNU compiling suite to work properly. My assumption is that this is due to the author/s creating the applications...
399
12888
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or to python-3000@python.org In summary, this PEP proposes to allow non-ASCII letters as identifiers in Python. If the PEP is accepted, the following identifiers would also become valid as class, function, or variable names: Löffelstiel,...
1
1945
by: bizt | last post by:
Hi, I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object requests is because I wish for some of my requests to be over a secure https:// connection and other not so private requests to be made over http:// .. using XmlHttpRequest I am unable to make requests between two domains http/ https from the one...
0
9561
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
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,...
0
8252
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
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...
0
6078
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
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...
1
3316
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
2
2791
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.