Remoting Server in C# Outlook COM Add-in?

M

Michael

I am writing an Outlook XP/2003 COM Add-in in C# (Visual Studio .NET 2003).
I would like to also act as a .NET remoting service that clients can connect
to for information. I've added this code to initialize the server component
in the Add-in:

// Set up the remote service.
try
{
HttpChannel myChannel = new HttpChannel(_RemotingPort);
ChannelServices.RegisterChannel(myChannel);
Type myType = typeof(ProjectStateSummaries);
RemotingConfiguration.RegisterWellKnownServiceType(myType,
_RemotingEndPointStr,
WellKnownObjectMode.Singleton);
}
catch (System.Exception e)
{
Log.Write(this, TraceLevel.Error, "Problem registering server remoting
channel.");
Log.Write(this, TraceLevel.Error, e);
}


However, when I look at the RegisterWellKnownServiceType results in
fuslogvw.exe, I get the results below. It appears as if the register call
can't find my own dll, perhaps since Outlook is not a .NET program.

Is there anything I can do to get the service registered properly so that I
can connect to it from C# clients? This product will be commercially
distributed, so I don't want to mess with the Outlook installation or
directories in inappropriate ways...

Michael


*** Assembly Binder Log Entry (2/18/2005 @ 5:45:06 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\fusion.dll
Running under executable C:\Program Files\Microsoft
Office\OFFICE11\OUTLOOK.EXE
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = IssueManager, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=a6ec1e3a68dfd681
(Fully-specified)
LOG: Appbase = C:\Program Files\Microsoft Office\OFFICE11\
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===

LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: IssueManager, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=a6ec1e3a68dfd681
LOG: Cache Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft
Office/OFFICE11/IssueManager.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft
Office/OFFICE11/IssueManager/IssueManager.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft
Office/OFFICE11/IssueManager.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft
Office/OFFICE11/IssueManager/IssueManager.EXE.
LOG: All probing URLs attempted and failed.
 
H

Helmut Obertanner

Maybe the problem is, that your AddIn is a dll and running in process of
Outlook.
Maybe write a second C# Programm (The remoting Server), that connects to
your Outlook AddIn and gets the Information you want from Outlook.

Greets, Helmut Obertanner
 
M

Michael

Yes, the fact that my C# Add-in is being loaded into Outlook is the problem.
My C# application (not the Add-in) can't connect to the C# Add-in because
the registration fails within the Add-in (see my original note). I did not
follow how your suggestion would help.

Any other ideas out there?

Michael

Maybe the problem is, that your AddIn is a dll and running in process of
Outlook.
Maybe write a second C# Programm (The remoting Server), that connects to
your Outlook AddIn and gets the Information you want from Outlook.

Greets, Helmut Obertanner
 
S

Sunny

I am writing an Outlook XP/2003 COM Add-in in C# (Visual Studio .NET 2003).
I would like to also act as a .NET remoting service that clients can connect
to for information. I've added this code to initialize the server component
in the Add-in:

// Set up the remote service.
try
{
HttpChannel myChannel = new HttpChannel(_RemotingPort);
ChannelServices.RegisterChannel(myChannel);
Type myType = typeof(ProjectStateSummaries);
RemotingConfiguration.RegisterWellKnownServiceType(myType,
_RemotingEndPointStr,
WellKnownObjectMode.Singleton);
}
catch (System.Exception e)
{
Log.Write(this, TraceLevel.Error, "Problem registering server remoting
channel.");
Log.Write(this, TraceLevel.Error, e);
}


However, when I look at the RegisterWellKnownServiceType results in
fuslogvw.exe, I get the results below. It appears as if the register call
can't find my own dll, perhaps since Outlook is not a .NET program.

Is there anything I can do to get the service registered properly so that I
can connect to it from C# clients? This product will be commercially
distributed, so I don't want to mess with the Outlook installation or
directories in inappropriate ways...

Michael


As the hosting process is Outlook, the build-in assembly resolver of the
framework tries to load the assembly from Outlook.exe's folder. Possible
solutions:

1. Put that assembly in GAC (I do not like this)
2. Use AppDomain.AssemblyResolve event and load the assembly manually.

Cheers
Sunny
 
C

Colin Stutley

Does the 'IssueManager' class need to be compiled to a separate dll?
If not could you embedd this class within the same assembly, this way you
only need to distribute the one file (and not the IssueManager.dll).

OR:
What does "Application.StartupPath" return?
I have not tested this with an add-in but you may be in luck and have it
return the base directory of your installed set. If it does then you can
manually load your assembly using this as the qualified path. You will need
to handle and sub-dependencies that 'IssueManager.dll' itself may have
though.

- Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top