473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET

Hello,

We have a situation where a managed C++ assembly links with native C++ dll.
There is a callback mechanism which calls back into the managed code
asynchronously. Since native classes cannot hold onto a managed reference,
we need to have a managed static member which we access during the callback
and then get into the managed code.

This works great in a console or WinForm app. But in ASP.NET it doesn't. The
reason is that each web site is loaded into its own AppDomain.

After some debugging we found out that the managed static is set on
AppDomain 2, but the callback happens on AppDomain 1 (the default domain).
When the callback code tries to access the managed static - it is undefined.

We found a way to do a call into a different AppDomain, but only when you
already have a reference to that AppDomain and we don't - there doesn't seem
to be a way to enumerate AppDomains in a process.

Has anybody else run into this?

Is there a way to have ASP.NET (or the CLR) to not load the native code into
the neutral domain, instead load it into each AppDomain?
Jan 10 '07 #1
2 1810

"Dave Burns" <db********@aol.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hello,

We have a situation where a managed C++ assembly links with native C++
dll.
There is a callback mechanism which calls back into the managed code
asynchronously. Since native classes cannot hold onto a managed reference,
Why not? There's gcroot and HandleRef and so forth to help with that.
we need to have a managed static member which we access during the
callback
and then get into the managed code.

This works great in a console or WinForm app. But in ASP.NET it doesn't.
The
reason is that each web site is loaded into its own AppDomain.

After some debugging we found out that the managed static is set on
AppDomain 2, but the callback happens on AppDomain 1 (the default domain).
When the callback code tries to access the managed static - it is
undefined.

We found a way to do a call into a different AppDomain, but only when you
already have a reference to that AppDomain and we don't - there doesn't
seem
to be a way to enumerate AppDomains in a process.

Has anybody else run into this?

Is there a way to have ASP.NET (or the CLR) to not load the native code
into
the neutral domain, instead load it into each AppDomain?


Jan 10 '07 #2
Thanks,

I tried gcroot as well, but same result - still can't call across
AppDomains.

dave

"Ben Voigt" <rb*@nospam.nospamwrote in message
news:uP**************@TK2MSFTNGP02.phx.gbl...
>
"Dave Burns" <db********@aol.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hello,

We have a situation where a managed C++ assembly links with native C++
dll.
There is a callback mechanism which calls back into the managed code
asynchronously. Since native classes cannot hold onto a managed
reference,
Why not? There's gcroot and HandleRef and so forth to help with that.
>we need to have a managed static member which we access during the
callback
and then get into the managed code.

This works great in a console or WinForm app. But in ASP.NET it doesn't.
The
reason is that each web site is loaded into its own AppDomain.

After some debugging we found out that the managed static is set on
AppDomain 2, but the callback happens on AppDomain 1 (the default
domain).
When the callback code tries to access the managed static - it is
undefined.

We found a way to do a call into a different AppDomain, but only when you
already have a reference to that AppDomain and we don't - there doesn't
seem
to be a way to enumerate AppDomains in a process.

Has anybody else run into this?

Is there a way to have ASP.NET (or the CLR) to not load the native code
into
the neutral domain, instead load it into each AppDomain?



Jan 12 '07 #3

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

Similar topics

4
by: Daylor | last post by:
in win32 process , when u create new process,u have new main thread. i know,appDomain r logical procces,that exists in 1 win32 process. the q: is there way to create second appDomain (the...
5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
15
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that...
8
by: Bern McCarty | last post by:
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...
4
by: Tim Menninger | last post by:
Just started working on this and have not found any real good resources out there. We have a lot of native C++ Dll code that we use for our app. We want to share the code so that C# ASP.net code...
1
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender,...
2
by: RalphTheExpert | last post by:
This thread is a continuation of a thread with the Subject "Unhandled exception - Different under debugger and non-debugger". (http://www.dotnetnewsgroups.com/newsgroupthread.asp?ID=186902) ...
6
by: pradeep_TP | last post by:
Hi all, I am using IIS 5.0 and this question is regarding working of ASP.net worker process. I have only one web application right now on my web server. This means that only one AppDomain will...
2
by: Dave Burns | last post by:
Hello, We have a situation where a managed C++ assembly links with native C++ dll. There is a callback mechanism which calls back into the managed code asynchronously. Since native classes...
2
by: siger99 | last post by:
Hi, I try to use a 3rd party assembly ( basically a layer of managed C++ around a native C++ lib). Unfortunately, it was developped for NET 1.1 and knows only the default AppDomain. When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.