Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET

Reply
Thread Tools

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

 
 
Dave Burns
Guest
Posts: n/a
 
      01-10-2007
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?


 
Reply With Quote
 
 
 
 
Ben Voigt
Guest
Posts: n/a
 
      01-10-2007

"Dave Burns" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
 
 
 
Dave Burns
Guest
Posts: n/a
 
      01-12-2007
Thanks,

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

dave

"Ben Voigt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "Dave Burns" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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?
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing appDomain members from another appDomain mrajanikrishna@gmail.com ASP .Net 1 09-13-2008 09:15 PM
VoipSWITCH 2.0.0.915+All Latest Modules+Hosted In Just 250$/pm,Now Start Your Own Calling Card/CallCentre/Pc2Phone/Ani,Sms,Web CallBack/CallShop/OnlineShop/VSR/VSC/Ivr Business In Just 250$ solution4voip VOIP 0 11-12-2007 10:39 PM
Calling from default AppDomain (native code) into another AppDomain (managed code), hosted by ASP.NET Dave Burns ASP .Net 0 01-12-2007 03:43 PM
Why does calling an ActiveX control from a winform hosted in IE take so long? jwinkler2083233@gmail.com ASP .Net 0 02-10-2006 01:03 AM
Calling an executable from an .aspx page hosted on Windows 2003 Marlene Arauz Martin ASP .Net 6 07-23-2004 01:22 PM



Advertisments