Re: Convert InProcServer to OutProc
From: Howard Swope (howardsnewsATspitzincDOTcom)
Date: 11/22/04
- Previous message: Ray: "MAPI problem"
- In reply to: Frank Lakmann: "Convert InProcServer to OutProc"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Nov 2004 16:19:48 -0500
Yes, it is possible to this. There are a few good samples that I ran across
searching the web, however, I didn't save a reference to them. You would be
better served by finding one of those. However, the basic process was not
too difficult.
1. Create an exe that references your .dll
2. Have your exe register the class factories for your creatable objects
3. Use regasm to register your .dll and create a type library
4. Manually replace any InprocServer32 registry entries that were added with
LocalServer entries
5. Manually add appropriate AppId registry entries
You will probably also find it helpful to define your own interfaces instead
of letting interop do it for you. You will want to make sure that you have
applied the appropriate Com attributes too.
As I mentioned I came across a few good tutorial web sites. They walked you
through the process step by step.
"Frank Lakmann" <lakmann@gmx.de> wrote in message
news:1d5cd7b3.0411221108.5d2a7bdb@posting.google.com...
> Hello,
> I created a COM Server .NET dll that works fine as an InProcServer. It
> creates it's own OdbcConnection and saves the passed data to DB.
> But the DB-connection of the application using this COM server gets
> messed up when the new connection is opened (some wierd ODBC 2 vs ODBC
> 3 stuff).
> The solution would be to run the COM Server in a separate process.
> First I read this is not possible in .NET (shocking!) then I stumbled
> over this sdk sample COMREG but couldn't get it to work.
> What do I have to do to convert my DLL into an OutProcServer?
> Can I use DllHost? Do I have to make an exe out of it? What would the
> Main Method look like and do I have to show a Form?
>
> I have little experience in COM programming and was happy the server
> worked.
> But now I am stuck. Please help.
>
> The "entry point" of the DLL is the class Application.
>
> using System;
> using System.Runtime.InteropServices;
> using ...
>
> namespace IkarosGMV.COM {
> /// <summary>
> /// Zusammenfassung für Application.
> /// </summary>
> [ClassInterface(ClassInterfaceType.AutoDual)]
> [Guid("D36F350B-7200-468f-8459-6BA8512BFD46")]
> public class Application {
> private Error _error;
>
> public Application() {
> _error = new Error();
> }
>
> public Error Error {
> get {return _error;}
> }
>
> public int AnzahlNeuerNachrichten {
> get {
> // get some data from db
> ......
> }
> return anz;
> }
> }
>
> public void LogIn(string DSN,string DBN, string UID, string PWD) {
> try {
> // creates new connection
> ......
>
> this._error.IsError = false;
> } catch (Exception exc) {
> _error.IsError = true;
> _error.Message = exc.GetType().FullName + ": " + exc.Message;
> }
> }
> // other methods and properties
> ......
> }
>
>
> The regfile otuput from COMREG looks like this:
> REGEDIT4
>
> [HKEY_CLASSES_ROOT\IkarosGMV.COM.Application]
> @="IkarosGMV.COM.Application"
>
> [HKEY_CLASSES_ROOT\IkarosGMV.COM.Application\CLSID]
> @="{D36F350B-7200-468F-8459-6BA8512BFD46}"
>
> [HKEY_CLASSES_ROOT\CLSID\{D36F350B-7200-468F-8459-6BA8512BFD46}]
> @="IkarosGMV.COM.Application"
> "AppID"="{D36F350B-7200-468F-8459-6BA8512BFD46}"
>
>
[HKEY_CLASSES_ROOT\CLSID\{D36F350B-7200-468F-8459-6BA8512BFD46}\InprocServer
32]
> @="mscoree.dll"
> "ThreadingModel"="Both"
> "Class"="IkarosGMV.COM.Application"
> "Assembly"="IkarosGMV.COM, Version=1.0.1781.16813, Culture=neutral,
> PublicKeyToken=85dfcfbcc43007db"
> "RuntimeVersion"="v1.1.4322"
> "Codebase"="file:///I:/Testumgebung/IKAROS-GMV/IkarosGMV.COM.DLL"
>
> [HKEY_CLASSES_ROOT\CLSID\{D36F350B-7200-468F-8459-6BA8512BFD46}\ProgId]
> @="IkarosGMV.COM.Application"
>
> [HKEY_CLASSES_ROOT\AppID\{D36F350B-7200-468F-8459-6BA8512BFD46}]
> @="IkarosGMV.COM.Application"
> "AppID"="{D36F350B-7200-468F-8459-6BA8512BFD46}"
> "DllSurrogate"=""
> "RunAs"="Interactive User"
>
>
[HKEY_CLASSES_ROOT\CLSID\{D36F350B-7200-468F-8459-6BA8512BFD46}\Implemented
> Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
> @=""
>
> [HKEY_CLASSES_ROOT\Component
> Category\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
> "0"=""
- Previous message: Ray: "MAPI problem"
- In reply to: Frank Lakmann: "Convert InProcServer to OutProc"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|