How to initalize COM from an ASP.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm developing an ASP page for my group at work that manages MS virtual
Server images. If i make a call to initalize com by using COInitializeEX and
security ect.. I get a dreadful meassage stating that i need to do this
before any marshalling ect.. are done.

It does not seem to matter were i do this (Page_Load, OnInit). Now i did
decide to not worrie about this and make the api calls i need to make inot
virtual server and it works, BUT, now when i try to get a class object of a
remote virtual server i'm getting an error and was wondering if its because i
didnt initialize COM.

So the question is. For web based apps (Web Services, ASP) do i have to
initialize com? If so how do i do it so i dont get that error ?

Thanks!
 
This isn't something you'd call from ASP.NET since you're being hosted in
someone else's app (aspnet_wp.exe or w3wp.exe). My recollection is that you
need to call CoInitSec to do certain things with the virtual server API,
yes? This isn't really going to fly in ASP.NET, so you'll need to build a
seperate Win32 process where you have control over the COM security model.
This can be done from managed code, but my recollection is that there are
some snaffus. So, you'll need to make this seperate process available via
remoting or some other IPC mechanism to your ASP.NET code.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Thanks a bunch Brock,

Guess its time to get a book or something and figure this out. I'm fairly
new to alot of this stuff so learning as i go. If ya got any good reads
please let me know.

Thanks
 
Oh gosh -- you're learning .NET *and* COM at the same time? That's quite
an endeavor. As for the best COM/.NET interop guide, check out ".NET and
COM The Complete Interoperability Guide" by Nathan.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
HeHe, yeah very painful but its been a great experiance. Thanks a bunch for
the tip ont he book. I will check it out.
 
Back
Top