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 / CLR / June 2006

Tip: Looking for answers? Try searching our database.

ICLRControl::GetCLRManager error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
noah.adler@gmail.com - 20 Jun 2006 17:15 GMT
I'm trying to write a custom CLR host for .NET 2.0 in order to revert
to the previous model of unloading the AppDomain when an unhandled
exception occurs, rather than bubbling it up and terminating the
process, which is the new standard behavior.  As I understand it, I
need to get a ICLRPolicyManager instance, from which I can easily alter
the unhandled exception handling.  However, my attempts to retrieve an
ICLRPolicyManager (or indeed _any_ manager) from
ICLRControl::GetCLRManager result in an HRESULT error code of
0x80131022.  In CorError.h I find that 0x801310yy range is reserved for
'Execution Engine' errors, but I can't find more specific information
than that.  Does anyone have any ideas?  Here's a sample illustrating
the problem:

#include <mscoree.h>
#include <CorError.h>
#include <iostream>
#include <cassert>

#import <mscorlib.tlb> raw_interfaces_only
high_property_prefixes("_get","_put","_putref")

int main() {
   ICLRRuntimeHost *host = 0;
   if (FAILED(CorBindToRuntimeEx(L"v2.0.50727", L"svr",
STARTUP_SERVER_GC | STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN,
CLSID_CLRRuntimeHost, IID_ICLRRuntimeHost, (PVOID*) &host))) {
       std::cerr << "Failed to initialize CLR" << std::endl;
       return -1;
   }

   ICLRControl *clrControl = 0;
   if (FAILED(host->GetCLRControl(&clrControl))) {
       std::cerr << "Failed to get CLR control" << std::endl;
       return -1;
   }

   ICLRPolicyManager *clrPolicyManager = 0;
   if (FAILED(clrControl->GetCLRManager(IID_ICLRPolicyManager,
(void**) &clrPolicyManager))) {
       std::cerr << "Failed to get CLR policy manager" << std::endl;
       return -1;
   }

   host->Start();

   host->Stop();
   host->Release();
}

For me, this always ends with 'Failed to get CLR policy manager,' with
the HRESULT failure code previously mentioned.  From all the examples
I've seen and documentation I've read, this should work.  Maybe I'm
missing something obvious; any help would be greatly appreciated.

Thanks,
noah adler
noah.adler@gmail.com - 20 Jun 2006 21:35 GMT
Well, I found that 0x80131022 maps to HOST_E_INVALIDOPERATION.
However, I still can't find any place in the documentation for
ICLRControl::GetCLRManager that explains why this call should return
such a value.  Can anyone shed some light?

Thanks again,
noah

> I'm trying to write a custom CLR host for .NET 2.0 in order to revert
> to the previous model of unloading the AppDomain when an unhandled
[quoted text clipped - 52 lines]
> Thanks,
> noah adler
noah.adler@gmail.com - 27 Jun 2006 19:41 GMT
Well, I found the problem.  In hindsight it seems obvious, but just in
case anyone in the future has the problem, I thought I'd document it
here.  I was passing the /clr switch to cl.exe, which linked in the
proper libraries and compiled with no problems, but caused these
unexpected errors to occur.  Omitting the /clr switch and manually
linking in mscoree.lib solved the problem for me.

Sorry for adding noise to the group, but hopefully it may help someone
else out in the future.

> Well, I found that 0x80131022 maps to HOST_E_INVALIDOPERATION.
> However, I still can't find any place in the documentation for
[quoted text clipped - 60 lines]
> > Thanks,
> > noah adler

Rate this thread:







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.