Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Burns - 10 Jan 2007 16:41 GMT
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?
Ben Voigt - 10 Jan 2007 18:46 GMT
> 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
[quoted text clipped - 19 lines]
> into
> the neutral domain, instead load it into each AppDomain?
Dave Burns - 12 Jan 2007 15:41 GMT
Thanks,

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

dave

>> Hello,
>>
[quoted text clipped - 29 lines]
>> into
>> the neutral domain, instead load it into each AppDomain?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.