By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,013 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,013 IT Pros & Developers. It's quick & easy.

Problem Invoking a .net dll (Class Library - com+)

P: n/a
Hi,

I am 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.GetOrCrea teProxy(Identity idObj,
Object proxy, Boolean fRefine)\r\n at
System.Runtime.Remoting.RemotingServices.InternalU nmarshal(ObjRef objectRef,
Object proxy, Boolean fRefine)\r\n at
System.Runtime.Remoting.RemotingServices.Unmarshal (ObjRef objectRef)\r\n
at
System.EnterpriseServices.ServicedComponentProxyAt tribute.CreateInstance(Type
serverType)\r\n at
System.Runtime.Remoting.Activation.ActivationServi ces.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.ReleaseComO bject(ObjMsp);

Thanks in advance
Dhandapani
Jun 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Dhandapani,

Thank you for your post!

After reviewing the problem description, I am not clear on some points.
Could you please help me on the following questions so that we can work
more closely?
1) Is the COM component exposed from .NET?
2) Is the component a COM+ component deployed in remote COM+ explorer?
3) From your posted stack trace, it seems the exception is thrown from the
call to Activator.CreateInstance(), which means the Type info is retrieved
successfully. Maybe you could Add Watch on the Type instance to see whether
or not the assembly is located correctly.

If there is any something you would like to add, please feel free to reply
here. I am happy to work with you on this.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Jun 6 '06 #2

P: n/a
Hi Praveen,

Based on my understanding, the question is:
1) You are building a ServicedComponent using Visual Studio 2003
2) You deployed it as a Server application in COM+ explorer
3) You are calling it using C# client with following code:

Type Obj = Type.GetTypeFromProgID(sClassName);
object ObjMsp = Activator.CreateInstance(Obj);

and get "Cannot load type" exception while calling "CreateInstance".

If I've misunderstood anything, please feel free to post here.

Based on my research, for Type.GetTypeFromProgID, if you don't provide
additional ServerName parameter, it's loading the type locally. Since a
COM+ server application runs in its own process, we must provide a
ServerName parameter to Type.GetTypeFromProgID to force it load the type
remotely with the Com Callable Wrapper (CCW). You can inspect the loaded
Type instance while debugging:

1) When not providing the ServerName parameter, the loaded assembly is the
locally installed one with the actual type
2) When providing the ServerName parameter, the loaded assembly is
mscorlib.dll, which is the actual COM implementation of all .NET exposed
components.

Actually, the recommended way to call a ServicedComponent built with .NET
from a .NET client is to reference the assembly and call with early-bind
rather than late-bind.

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Jun 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.