(i) Is there is some deep flaw in writing out-of-process COM servers in .NET
?
I only ask because
(a) In the IDE the "Register for COM Interop" checkbox is
disabled in the Project Property Pages\Configuration Properties\Build dialog
page if you have a Windows project. If not why is it greyed out?
(b) I can't find any code examples anywhere (even in Adam
Nathans .NET and COM: The Complete Interoperability Guide).
(ii) In VB you have the App.StartMode which indicates whether the
application has been started as a COM server or in a standalone mode.
Further whichever way that application is started by setting the appropriate
properties you can arrange for Sub Main to be called (though of course if
you don't get out of it pretty quickly you'll get a COM timeout error). How
does application startup work for a COM Interop component in .NET?
I think I'm probably in the same boat as a lot of developers where
interoperability with applications such as Excel is very important. As Excel
does not quite yet talk .NET it is necessary to write COM interobjects:
particularly to provide services such as RTDServers and objects that can be
called from within VBA. Is the new way forward to write in-process COM
interop objects which then communicate with the main application through
remoting or perhaps alternatively to write applications as class libraries
and have an orchestrating windows service to provide the application domain
for them to live in?
So (i) any suggestions how to architect a .NET application that needs to
communicate with Excel both via RTD and by being controllable via VBA
macros, although it needs to be able to run stand alone?
and (ii) if you can write out-of-process COM Servers in VB.NET what steps
are involved and how is application startup controlled?
Thanks
for a 'weak 30% workaround', check:
...FrameworkSDK...\Samples\Technologies\Interop\Advanced\comreg\readme.htm
or read about COM+ / System.EnterpriseServices.ServicedComponent
(needs redesign of clients?, win2000+ only)
or do a complete rewrite, clients & server using 'remoting'
"Nicholas Free" <nick...@NOSPAMticklogic.com> wrote in message news:#LFZcZY1BHA.2792@tkmsftngp05...
> I'm trying to get my head around how to write what I would have previously
> written as an out-of-process COM Server, in VB.NET. I was wondering if
> someone could give me a heads up on the subject? In particular
> (i) Is there is some deep flaw in writing out-of-process COM servers in .NET
step1: Implement IClassFactory in a class in .NET
step2:
[DllImport("ole32.dll")]
private static extern int CoRegisterClassObject(ref Guid rclsid,
[MarshalAs(UnmanagedType.Interface)]IClassFactory pUnkn, int dwClsContext,
int flags, out int lpdwRegister);
[DllImport("ole32.dll")]
private static extern int CoRevokeClassObject(int dwRegister);
step 3: use these functions to register your own IClassFactory
step 4: IClassFactory has a CreateInstance method. Implement this method to
return a reference (IntPtr) to your own object. (use
Marshal.GetIUnknownForObject to get IUnknown pointer to your object...)
step 5: the COM client receives a pointer to this object, and can use it as
a regular COM object. .NET does the reference counting for you, and the GC
will collect these objects if the COM-reference-count == 0
First examine the working of ClassFactories for COM. Then you will see the
objects you need to implement in .NET, and a sollution in pure managed "C#"
is possible.
Peter Vermeesch
www.i-systems.be
"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:#mKU50Y1BHA.368@tkmsftngp02...
For NON-singleton (new instance per client),
the call to:
Namespace: System.Runtime.InteropServices
RegistrationServices.RegisterTypeForComClients
seems to do something similar.
"Peter Vermeesch" <PV...@hotmail.com> wrote in message news:OJ5KvLo1BHA.2212@tkmsftngp05...
> No weak workarounds... it is possible...
> step1: Implement IClassFactory in a class in .NET
> step2:
> private static extern int CoRegisterClassObject(ref Guid rclsid,
> private static extern int CoRevokeClassObject(int dwRegister);
--
Steve Maillet (eMVP - Windows CE)
Entelechy Consulting
smaillet AT EntelechyConsulting DOT Com
"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:#V3kr1w1BHA.1796@tkmsftngp02...
the wrong line is (top of page):
"Adds the appropriate registry entries for the specified type using the specified GUID."
the more correct line is:
"This method is equivalent to calling CoRegisterClassObject in COM."
>> There doesn't appear to be any coresponding unregister
I didn't find one yet.
NETMaster
http://www.cetus-links.org/oo_csharp.html
"Steve Maillet (eMVP)" <nos...@nospam.com> wrote in message news:eyZTOz21BHA.2516@tkmsftngp04...
> That's an interesting function. Too bad it isn't really documented (yes
> there are entries for it in the docs with some verbiage but it's about as
> usefull as a hole in the head with some sense of the greater context it's
> supposed to be used in). There doesn't appear to be any coresponding
> unregister and once you've registered how do you ensure the app doesn't shut
> down until all clients are done using the provided components?
> Steve Maillet (eMVP - Windows CE)
> Entelechy Consulting
> smaillet AT EntelechyConsulting DOT Com
> "NETMaster" <spam.ne...@swissonline.ch> wrote in message