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

C#

 
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 
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 
MFC is still native, just native class wrappers for native Win32 APIs. All the COM interfaces necessary are already declared in other headers.

.NET, on the other hand, uses a completely different runtime that works with COM. Some native COM interfaces are re-declared in .NET, but only what is necessary. Anything else is left up to you.

So, it's not that MFC defined all the necessary interfaces - it didn't - but that MFC was native and the COM headers, libs, etc. were native so they went hand in hand.

You really should read about OLE and COM automation before starting such a project. There's a lot of fundamental concepts you need to understand, and COM is a very difficult things to understand (especially the automation interfaces that you would need to use).

Nick's article is not about using a .NET DLL in MFC. That's not even possible unless you're hosting your own AppDomain (this is documented in the .NET Framework SDK as well, under Hosting the Common Language Runtime[^].It's about exposing an assembly as a COM server that MFC can use like any COM server (no matter in what language it was written). As I mentioned before, in this case the default shim registered by regasm.exe - mscoree.dll - is actually loaded into process memory and it hosts the CLR and marshals calls to the .NET assembly (at this point, in what language the assembly was written is moot - all managed languages targeting the CLR compile to IL - that's the point of the Common Language Infrastructure (CLI) on what the .NET Framework (Microsoft's brand) is based).

Read through the documentation at http://msdn.microsoft.com/library/en-us/automat/htm/autoportal_7l45.asp[^] for a better understand of OLE and COM automation.

As far as .NET Remoting goes, you need to weigh your options. So you want to host a managed COM control in MFC that marshals calls across application boundaries to another application? You do realize what's involved, don't you?

First you're marshaling from unmanaged to managed code (and later, back again). Performance hit. Then you're marshaling serializable data (and you have to declare it using the SerializableAttribute and, optionally, implementing the ISerializable interface or using an ISerializationSurrogate implementation with a custom SerializationBinder across TCP ports (the fastest without defining your own custom remoting channels, until .NET 2.0 comes out with an IcpChannel implementation for IPC through named pipes). Then all that repeats in reverse to marshal data back.

And .NET Remoting is a difficult topic, too. Read Accessing Objects in other Application Domains[^] in the .NET Framework SDK for more information.

There's no easy way, and I'm not trying to discourage you, but you really need to read about your options.

The other way is to P/Invoke the necessary native APIs in your managed code and use named pipes to implement a client/server application, which is pretty straight forward.

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 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 
GeneralRe: Close Windows Form automatically Pin
Judah Gabriel Himango2-Dec-04 7:34
sponsorJudah Gabriel Himango2-Dec-04 7:34 
GeneralRe: Close Windows Form automatically Pin
Heath Stewart2-Dec-04 7:40
protectorHeath Stewart2-Dec-04 7:40 
GeneralChange text color on a single line Pin
Gywox2-Dec-04 5:45
Gywox2-Dec-04 5:45 
GeneralTest for file lock Pin
Marc Clifton2-Dec-04 5:16
mvaMarc Clifton2-Dec-04 5:16 

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.