Click here to Skip to main content
16,004,529 members
Home / Discussions / C#
   

C#

 
GeneralMSMQ in C# Pin
ppp00119-Oct-04 9:00
ppp00119-Oct-04 9:00 
GeneralRe: MSMQ in C# Pin
Heath Stewart19-Oct-04 11:17
protectorHeath Stewart19-Oct-04 11:17 
GeneralMCE SDK 2005 problem Pin
Oguz Mazlum19-Oct-04 7:48
Oguz Mazlum19-Oct-04 7:48 
GeneralRe: MCE SDK 2005 problem Pin
Heath Stewart19-Oct-04 11:12
protectorHeath Stewart19-Oct-04 11:12 
GeneralRe: MCE SDK 2005 problem Pin
Oguz Mazlum19-Oct-04 11:46
Oguz Mazlum19-Oct-04 11:46 
GeneralRe: MCE SDK 2005 problem Pin
Heath Stewart19-Oct-04 12:50
protectorHeath Stewart19-Oct-04 12:50 
GeneralRe: MCE SDK 2005 problem Pin
Oguz Mazlum19-Oct-04 13:08
Oguz Mazlum19-Oct-04 13:08 
GeneralRe: MCE SDK 2005 problem Pin
Heath Stewart19-Oct-04 15:01
protectorHeath Stewart19-Oct-04 15:01 
The fact that you have to register a component category (which you can do programmatically when regasm.exe is called on your assembly; read about the ComRegisterFunctionAttribute and ComUnregisterFunctionAttribute classes in the .NET Framework - which run in addition to the normal registration) means that some COM client is going to use ICatInformation::EnumClassesOfCategories (or equivalent) to get COM servers implementing supported interfaces. Your DLL is one such COM server. The MSAS is a COM server that is actually querying for this information about implementations such as your state service. BTW - you should not be installing your files into the system directory. Since your using regasm.exe you can install them anyway (but keep them there), or - better yet (recommended) sign the assembly (more secure anyway) and install it into the GAC using gacutil.exe and then use regasm.exe MSASState.dll (no /codebase, which tells the mscoree.dll shim to look in the GAC).

It's your job as the developer of this sink to communicate your data to whatever client you want. With .NET, your best approach is to use .NET Remoting.

If you haven't already, read Retrieving Media Status[^] in the SDK that explains how the MSAS loads the sinks (your assembly, acting as a COM server indirectly through the mscoree.dll shim).

And creating a Windows Forms application that references this assembly won't do any good - you need to reference the object that MSAS has loaded. This is where .NET Remoting comes in. You need to communicate this data between the AppDomain that was created for your sink and the AppDomain for your Windows Forms application (using statis will not work - each AppDomain is a separate context).

Read the .NET Remoting Overview[^]. There's also several good articles on this site about .NET Remoting, as well as a couple good books like "Microsoft .NET Remoting" from Microsoft Press[^] and "Advanced .NET Remoting" by Ingo Rammer[^].

Another way - though pretty difficult and more intensive (requires lots of marshaling) - is to register your MSAS sink with the ROT (Running Object Table) then using a moniker in your Windows Forms application to get it back out. The problems with this approach are many:
  • You must marshal data from unmanaged to managed to unmanaged to unmanaged to managed (that seems right) in one direction, and vice versa for the other (to call methods on the running object).
  • You must P/Invoke many native functions and re-declare several COM interfaces in managed code (see ComImportAttribute for starters) manually since several of these won't interop correctly using VS.NET or tlbimp.exe (like methods that can return S_FALSE, which is still a success code)
  • Your adding complexity to a design that will most likely introduce bugs
  • You really end up writing a COM client and server in managed code, not taking advantage of the managed features of the CLR.


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]
GeneralAnimating .x files with MDX9 Pin
JDUK19-Oct-04 6:21
JDUK19-Oct-04 6:21 
GeneralRe: Animating .x files with MDX9 Pin
Heath Stewart19-Oct-04 7:26
protectorHeath Stewart19-Oct-04 7:26 
GeneralRe: Animating .x files with MDX9 Pin
JDUK19-Oct-04 7:41
JDUK19-Oct-04 7:41 
GeneralRe: Animating .x files with MDX9 Pin
Heath Stewart19-Oct-04 8:02
protectorHeath Stewart19-Oct-04 8:02 
GeneralRe: Animating .x files with MDX9 Pin
JDUK19-Oct-04 8:20
JDUK19-Oct-04 8:20 
GeneralRe: Animating .x files with MDX9 Pin
JDUK19-Oct-04 22:23
JDUK19-Oct-04 22:23 
GeneralVoice recognition Pin
amatyasik19-Oct-04 5:06
amatyasik19-Oct-04 5:06 
GeneralRe: Voice recognition Pin
tom_dx19-Oct-04 13:38
tom_dx19-Oct-04 13:38 
GeneralTAPI Pin
rpussewela19-Oct-04 4:41
rpussewela19-Oct-04 4:41 
GeneralRe: TAPI Pin
Dave Kreskowiak19-Oct-04 8:33
mveDave Kreskowiak19-Oct-04 8:33 
GeneralRe: TAPI Pin
rpussewela19-Oct-04 20:38
rpussewela19-Oct-04 20:38 
GeneralRe: TAPI Pin
Nick Parker19-Oct-04 12:45
protectorNick Parker19-Oct-04 12:45 
GeneralUI Thread Pin
eDip19-Oct-04 4:39
eDip19-Oct-04 4:39 
GeneralRe: UI Thread Pin
Stefan Troschuetz19-Oct-04 5:08
Stefan Troschuetz19-Oct-04 5:08 
GeneralRe: UI Thread Pin
Michael Potter19-Oct-04 5:10
Michael Potter19-Oct-04 5:10 
GeneralRe: UI Thread Pin
eDip20-Oct-04 0:11
eDip20-Oct-04 0:11 
GeneralRe: UI Thread Pin
Michael Potter20-Oct-04 4:06
Michael Potter20-Oct-04 4:06 

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.