473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM+ Interop problem

Hi.

I am using a COM component from managed code doing the following:

Type type = Type.GetTypeFro mCLSID(new
Guid("B70FAAE6-4F85-480A-B1C5-DC9A6F175BFC"), serverMachineNa me, true);
history = Activator.Creat eInstance(type) as HistoryClass;

This works on the local machine, no problem whatsoever. But when I run the
client remotely, the cast in the second line of code shown above fails.

I do get an object, I do see the component being activated on the server,
but casting the object to the HistoryClass type (which is from a proxy dll
produced by tlbimp) does no longer result in a valid object. I either get
null if I use "as HistoryClass" as shown above or I get a runtime error
saying the cast is invalid if I use "(HistoryClass) " before Activator. So I
can't use the object, the proxy seems disfunctional.

I tried casting to the interface instead (I have an IHistory interface
implemented by the class object which is the one I need) but to no avail.

Can someone who is the greater COM Interop expert shed some light on this
please? (preferably showing me how to do it right) ?

Regards, Martin.
Nov 16 '05 #1
4 2721
Use

Activator.GetOb ject instead of Activator.Creat eInstance.

--
Shak
(Houston)
"Martin Maat" <du***@somewher e.nl> wrote in message
news:10******** *****@corp.supe rnews.com...
Hi.

I am using a COM component from managed code doing the following:

Type type = Type.GetTypeFro mCLSID(new
Guid("B70FAAE6-4F85-480A-B1C5-DC9A6F175BFC"), serverMachineNa me, true);
history = Activator.Creat eInstance(type) as HistoryClass;

This works on the local machine, no problem whatsoever. But when I run the
client remotely, the cast in the second line of code shown above fails.

I do get an object, I do see the component being activated on the server,
but casting the object to the HistoryClass type (which is from a proxy dll
produced by tlbimp) does no longer result in a valid object. I either get
null if I use "as HistoryClass" as shown above or I get a runtime error
saying the cast is invalid if I use "(HistoryClass) " before Activator. So I can't use the object, the proxy seems disfunctional.

I tried casting to the interface instead (I have an IHistory interface
implemented by the class object which is the one I need) but to no avail.

Can someone who is the greater COM Interop expert shed some light on this
please? (preferably showing me how to do it right) ?

Regards, Martin.

Nov 16 '05 #2
"Shakir Hussain" <sh**@fakedomai n.com> wrote in message
news:uP******** *****@tk2msftng p13.phx.gbl...
Hi.

I am using a COM component from managed code doing the following:

Type type = Type.GetTypeFro mCLSID(new
Guid("B70FAAE6-4F85-480A-B1C5-DC9A6F175BFC"), serverMachineNa me, true);
history = Activator.Creat eInstance(type) as HistoryClass;

This works on the local machine, no problem whatsoever. But when I run the client remotely, the cast in the second line of code shown above fails.

I do get an object, I do see the component being activated on the server, but casting the object to the HistoryClass type (which is from a proxy dll produced by tlbimp) does no longer result in a valid object. I either get null if I use "as HistoryClass" as shown above or I get a runtime error
saying the cast is invalid if I use "(HistoryClass) " before Activator. So I can't use the object, the proxy seems disfunctional.

I tried casting to the interface instead (I have an IHistory interface
implemented by the class object which is the one I need) but to no avail.
Can someone who is the greater COM Interop expert shed some light on this please? (preferably showing me how to do it right) ?
Use Activator.GetOb ject instead of Activator.Creat eInstance.


I have to specify a URL with this method and after trying several I still
get nothing but error messages. The most common are:

"Invalid URL"
"No connection could be made because the target machine actively refused it"
(and this would still be the local machine)

I must say I hardly know what I am doing when specifying the URL, I read it
is mostly used to target modules that are hosted in IIS which makes sense. I
am however targeting a COM component on a remote machine, should my URL
include the friendly class name? The server module? Just the machine and a
port number? What port number? I tried both tcp:// and http:// URLs.
I then reverted to this approach:

object obj = Activator.Creat eInstance(type) ;
history = Marshal.CreateW rapperOfType(ob j, typeof(HistoryC lass)) as
IHistory;

which worked beautifully again locally, yet gave me
"Source object cannot be converted to the destination type since it does not
support all the required interfaces"
on a remote client machine.

My component is OLE automation compliant, it has dual interfaces.

For the moment both server and client machines are running Windows XP. Any
idea's would be greatly appreciated.

Regards, Martin.
Nov 16 '05 #3
I should add that I just discovered classic COM clients not to work anymore
remotely either, giving me "Interface not supported". So the latter approach
may be just fine, I am having some old fashioned COM-trouble here.

Martin.
Nov 16 '05 #4
"Martin Maat" <du***@somewher e.nl> wrote in message
news:10******** *****@corp.supe rnews.com...
I should add that I just discovered classic COM clients not to work anymore remotely either, giving me "Interface not supported". So the latter approach may be just fine, I am having some old fashioned COM-trouble here.


The machines were not both members of the same domain. Once I had the client
join the domain the server machine was in I had no problems anymore. I can
still log on locally on the client machine and it still works, I don't have
to be logged on to the domain on both machines. Apperently the machines just
did not trust eachother enough.

Martin.
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
13411
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class template and by setting output to a type library (DLL). All the object does is return a string value. At this point I have not checked the option to register for COM interop in Visual Studio So I go into Excel (where I want to use the object). Go to VB...
4
2641
by: W1ld0ne74 | last post by:
I have rewritten a VB6 COM+ object using C# .Net. The object works as expected and registers itself in COM+ on my PC, the development server and even on the Test server. I did battle with this problem on the test server, but it seemed to resolve itself. This problem however is not resolving itself on the Production server. The COM+ object chats with a 3rd party dll (Registered using Regsrv32) via an Interop proxy dll. All are in the same...
1
1999
by: Nadav | last post by:
Hi, Introduction *************** I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer, this layer manage the underlying COM Objects and upon request, provide a pointer to those objects to the 'API Consumer', following is an illustration of the system: API Consumer ( Native C++/C# ) || ******************************************* * ...
15
6751
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use javascript or vbscript it works. I will appreciate any help. I do the following (C#):
1
3042
by: Bernd Muent | last post by:
Hi together, I am using the following code in Visual Basic to open Word or Excel applications: Word: Dim w As Word.Application w = CType(CreateObject("Word.application"), Word.Application) w.Application.Documents.Open("test.doc") With w.Application.Selection
5
2520
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj);
4
14300
by: Michael Maes | last post by:
Hi, On closing our App, we get following 'InvalidComObjectException': "COM object that has been separated from its underlying RCW cannot be used" The App has been upgraded from .Net1.1 to .Net2.0 a long time ago. Recently we started using the Application Framework, combined with a Splash Screen. About that moment we are having this issue. I thought the problem only existed while debugging, but now ,having a
2
7305
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a "Array index out of bounds". Microsoft.Office.Interop.Outlook._Application olApp = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook._NameSpace olNs = olApp.GetNamespace("MAPI");
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10370
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10113
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.