473,387 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
2 1933
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
1
by: TheOne | last post by:
I have two classes: class OntologyParser { ... protected: virtual void startElement(void *userData, const char *name, const char **atts); virtual void endElement(void *userData, const char...
1
by: Andrea | last post by:
I was trying to deserialize my xml file (I enclose it below ) into a class. So I generated an xsd file given my xml using the MS xsd tool; then I generated the corresponsing C# class (using the MS...
0
by: Michal | last post by:
Hi. I've been searching all over the internet, and I didn't find solution of my problem :( I hope someone can help me here... The problem is: Im writing a library in C# (COM Library). This...
0
by: graciezzzzz | last post by:
Hi all, I create a Web Service project called 'eSelectService' and another Class Library project called 'MonerisVO', and a Windows Form project called 'maps' as well. The reason why I need...
22
by: ypjofficial | last post by:
Is there any possibility of invoking the member functions of a class without creating an object (or even a pointer to ) of that class. eg. #include <iostream.h> class test { public: void...
4
by: ma740988 | last post by:
Trying to build on something I picked up from a Scott Meyers. Consider: class BaseMenuItem { public: virtual void invoke() const = 0; }; template<class Class, class MemFuncPtr, class...
2
by: gwoodhouse | last post by:
Hello all, I have an application at the moment which uses forms. The main form (which has ALOT of things going on it in) also happens to do alot of network proccess's which ive put in Threads. ...
2
by: Bob.Sidebotham | last post by:
If I run the following code: class path(object): def __init__(self, **subdirs): for name, path in subdirs.iteritems(): def getpath(): return path setattr(self, name, getpath) export = path(
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.