Click here to Skip to main content
15,915,864 members
Home / Discussions / C#
   

C#

 
GeneralUnicode text entry for RichTextBox differs from other edit tools....Why Pin
Jay Shankar2-Dec-04 15:22
Jay Shankar2-Dec-04 15:22 
GeneralChanging screen resolution Pin
Anonymous2-Dec-04 13:41
Anonymous2-Dec-04 13:41 
GeneralRe: Changing screen resolution Pin
Dave Kreskowiak2-Dec-04 16:14
mveDave Kreskowiak2-Dec-04 16:14 
GeneralRe: Changing screen resolution Pin
Alex Korchemniy2-Dec-04 16:28
Alex Korchemniy2-Dec-04 16:28 
GeneralRe: Changing screen resolution Pin
Anonymous3-Dec-04 3:08
Anonymous3-Dec-04 3:08 
GeneralRe: Changing screen resolution Pin
Alex Korchemniy3-Dec-04 3:21
Alex Korchemniy3-Dec-04 3:21 
GeneralAutomation server in C# Pin
Member 871962-Dec-04 10:22
Member 871962-Dec-04 10:22 
GeneralRe: Automation server in C# Pin
Heath Stewart2-Dec-04 11:22
protectorHeath Stewart2-Dec-04 11:22 
Given the wording of your sentance, I take it you mean an automation server as an EXE.

Before starting down that long and winding road, be sure to first read about proper exposition of .NET components to COM by reading Exposing .NET Framework Components to COM[^], Marshaling Data with COM Interop[^], and Nick's Exposing .NET Components to COM[^], which covers a few caveats that the SDK docs didn't mention originally - basically about following COM guidelines:
  • Always attributes classes and interfaces with static GUIDs using the GuidAttribute
  • Never change CLSIDs or IIDs for a particular version of an interface
  • Never change the definition of a published interfaces; derive a new version from the old and implement that interface as the first interface on the class
  • Et cetera...
To create an automation server, however, takes a lot more work. If you want only a single-instance automation server, there's a lot to do, including interop'ing moniker APIs and interfaces, as well as making use of the ROT (Running Object Table) to register your single instance (the moniker is to respond to access requests to the ROT item that represents your application). If you've done this natively, you've got a good start. Now you just need to P/Invoke the native APIs necessary and declare the managed version of interfaces (don't forget their IIDs for their GuidAttribute, as well as the ComImportAttribute that allows the CLR to marshal from COM to .NET and back again). Depending on the derivation of the interfaces, methods have to be declared in order and with the right DispIdAttribute values.

If you want the easy way, then instead of registering into the InProcServer32 registry key, you need to register into the LocalServer32 key. You can do this and still support registration using the regasm.exe tool but attributing a couple of static methods with the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute. Use the Microsoft.Win32.Registry and RegistryKey classes defined in the .NET BCL (may not - and probably not - available in other CLI implementations' class libraries) to get the CLSID for your attributed class (or hard-code them, since CLSIDs should never change anyway) and register the path to your executable (not to the mscoree.dll shim like COM servers of the DLL variety do).

You should also support the /automation command-line argument in your Main entry point and enable any automation facilities if necessary. At least eat the switch and don't report an error (and/or quit).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: Automation server in C# Pin
Member 871963-Dec-04 5:00
Member 871963-Dec-04 5:00 
GeneralRe: Automation server in C# Pin
Heath Stewart3-Dec-04 7:11
protectorHeath Stewart3-Dec-04 7:11 
GeneralRe: Automation server in C# Pin
Member 871963-Dec-04 8:12
Member 871963-Dec-04 8:12 
GeneralRe: Automation server in C# Pin
Heath Stewart3-Dec-04 8:44
protectorHeath Stewart3-Dec-04 8:44 
GeneralRe: Automation server in C# Pin
Member 8719615-Dec-04 3:14
Member 8719615-Dec-04 3:14 
GeneralRe: Automation server in C# Pin
Heath Stewart15-Dec-04 5:25
protectorHeath Stewart15-Dec-04 5:25 
GeneralRe: Automation server in C# Pin
Member 8719615-Dec-04 6:26
Member 8719615-Dec-04 6:26 
GeneralRe: Automation server in C# Pin
Member 8719615-Dec-04 6:22
Member 8719615-Dec-04 6:22 
GeneralRe: Automation server in C# Pin
Heath Stewart15-Dec-04 6:50
protectorHeath Stewart15-Dec-04 6:50 
GeneralInstalling .NET Framework Pin
Ami Bar2-Dec-04 9:26
Ami Bar2-Dec-04 9:26 
GeneralRe: Installing .NET Framework Pin
Heath Stewart2-Dec-04 11:03
protectorHeath Stewart2-Dec-04 11:03 
GeneralRe: Installing .NET Framework Pin
Daniel Turini2-Dec-04 11:32
Daniel Turini2-Dec-04 11:32 
GeneralDownload files ListBox and Thread Pin
fredza2-Dec-04 8:28
fredza2-Dec-04 8:28 
GeneralRe: Download files ListBox and Thread Pin
Nick Parker2-Dec-04 9:31
protectorNick Parker2-Dec-04 9:31 
GeneralRe: Download files ListBox and Thread Pin
fredza2-Dec-04 10:04
fredza2-Dec-04 10:04 
GeneralRe: Download files ListBox and Thread Pin
Heath Stewart2-Dec-04 11:08
protectorHeath Stewart2-Dec-04 11:08 
GeneralClose Windows Form automatically Pin
realmontanakid2-Dec-04 6:27
realmontanakid2-Dec-04 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.