all groups > dotnet component services > april 2006 >
You're in the

dotnet component services

group:

Invoking COM / .NET DLLs from Windows Service


Invoking COM / .NET DLLs from Windows Service Praveen
4/27/2006 10:57:53 PM
dotnet component services:
Hi,



We are developing a .NET application which will invoke the methods from
different COM / .NET DLLs. While invoking methods from .NET DLLs, I am
encountering the following error. I have also included the detail of the
error stack trace and the code that I have written to invoking the methods.



I would appreciate if you could let me know the cause of this error and
possible workarounds to avoid this situation.



Error Message



Cannot load type OrchServerSync.ASrvrSync, OrchServerSync, Version=3.0.6.0,
Culture=neutral, PublicKeyToken=5552a996b9dd0e5d.



Error StackTrace



at System.Runtime.Remoting.RemotingServices.GetOrCreateProxy(Identity idObj,
Object proxy, Boolean fRefine)\r\n at
System.Runtime.Remoting.RemotingServices.InternalUnmarshal(ObjRef objectRef,
Object proxy, Boolean fRefine)\r\n at
System.Runtime.Remoting.RemotingServices.Unmarshal(ObjRef objectRef)\r\n
at
System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type
serverType)\r\n at
System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type
serverType, Object[] props, Boolean bNewObj)\r\n at
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly)\r\n at
System.Activator.CreateInstance(Type type, Boolean nonPublic)\r\n at
System.Activator.CreateInstance(Type type)



Code used for Invoking:



object retObj = null;

Type Obj = Type.GetTypeFromProgID(sClassName);

object ObjMsp = Activator.CreateInstance(Obj);

retObj = Obj.InvokeMember(sMethodName, BindingFlags.InvokeMethod, null,
ObjMsp, null);

System.Runtime.InteropServices.Marshal.ReleaseComObject(ObjMsp);




Re: Invoking COM / .NET DLLs from Windows Service Tasos Vogiatzoglou
5/20/2006 4:03:03 AM
Where does your .NET assembly reside ? Is it COM-Interop enabled ?
Re: Invoking COM / .NET DLLs from Windows Service Praveen Chandra
6/5/2006 6:26:28 PM
Hi,

It is a serviced component and is interop enabled.

Below is the code, which we have used...

-------------------------------------------------------------------------=
-------------------------------------------------------------------------=
----------------------------------------------------------------
namespace Orchestra
{
/// <summary>
/// Summary description for Class1.
/// </summary>
[InterfaceTypeAttribute( ComInterfaceType.InterfaceIsDual )]
[GuidAttribute("805A7474-5669-4011-B59E-C671DDE6DF12")]
public interface IOpenSpirit
{
void TestInvoke();
}
[ EventTrackingEnabled( true ) ]
[ ObjectPooling( MinPoolSize =3D 1, MaxPoolSize =3D 10, CreationTimeout =
=3D 60000 ) ]
/// Specify COM+ Context Attributes
[ MustRunInClientContext( false ) ]
/// Enable JITA for the component
[ JustInTimeActivation( true ) ]
/// Enable Construction String Support for the component
/// Configure activity-based Synchronization for the component
[ Synchronization( SynchronizationOption.Required ) ]
/// Indicate the type of class interface that will be generated for this =
class
[ ClassInterface( ClassInterfaceType.None ) ]
public class WDTrack:ServicedComponent, IOpenSpirit
{
.....

-------------------------------------------------------------------------=
-------------------------------------------------------------------------=
----------------------------------------------------------------

[quoted text, click to view]
AddThis Social Bookmark Button