473,387 Members | 1,497 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.

Executing COM+ class

I am trying to execute following code:

Type type = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(type);

and get following RemotingException (in 2-nd line):

Cannot load type SomeType.SomeClass, SomeType.SomeClass,
Version=1.0.2658.25296, Culture=neutral, PublicKeyToken=null

There is no other info why it breaks. I can't figure out what is going
wrong.
SomeType.SomeClass is installed as a COM+ component. I checked "type"
for null and it's not null.
Any help would be appreciated.

Apr 30 '07 #1
7 2280
Slavan,

Is SomeType.SomeClass a .NET component? If so, you need to have a
reference to the original assembly and create the type using the new
keyword. .NET components hosted in COM+ can not be created in .NET through
COM interop (which is essentially what you are trying to do, if this is the
case).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Slavan" <vy*****************@gmail.comwrote in message
news:11**********************@c35g2000hsg.googlegr oups.com...
>I am trying to execute following code:

Type type = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(type);

and get following RemotingException (in 2-nd line):

Cannot load type SomeType.SomeClass, SomeType.SomeClass,
Version=1.0.2658.25296, Culture=neutral, PublicKeyToken=null

There is no other info why it breaks. I can't figure out what is going
wrong.
SomeType.SomeClass is installed as a COM+ component. I checked "type"
for null and it's not null.
Any help would be appreciated.

Apr 30 '07 #2
On Apr 30, 3:46 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Slavan,

Is SomeType.SomeClass a .NET component? If so, you need to have a
reference to the original assembly and create the type using the new
keyword. .NET components hosted in COM+ can not be created in .NET through
COM interop (which is essentially what you are trying to do, if this is the
case).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Slavan" <vyacheslav.vasyl...@gmail.comwrote in message

news:11**********************@c35g2000hsg.googlegr oups.com...
I am trying to execute following code:
Type type = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(type);
and get following RemotingException (in 2-nd line):
Cannot load type SomeType.SomeClass, SomeType.SomeClass,
Version=1.0.2658.25296, Culture=neutral, PublicKeyToken=null
There is no other info why it breaks. I can't figure out what is going
wrong.
SomeType.SomeClass is installed as a COM+ component. I checked "type"
for null and it's not null.
Any help would be appreciated.- Hide quoted text -

- Show quoted text -
Thanks for reply, SomeType.SomeClass is indeed a .NET component hosted
as COM+ class.
Is there any other way to use it. I don't want to create a reference
to dll, since it's location will be unknown at install?

Apr 30 '07 #3
You could try running FUSLOGVW (the Fusion Log Viewer) from a Visual Studio
Command Prompt to capture a trace of the process that your program is doing
while trying to locate the DLLs. This could give you a clue as to what is
missing. For instance, maybe the component is registered in COM+, but the
..Net assembly is neither in the GAC nor in a folder that is searched by the
fusion process. Indeed, looking at the error "Version=1.0.2658.25296, ...
PublicKeyToken=null", it looks like the assembly does not have a strong
name, and therefore it can't be in the GAC.

"Slavan" <vy*****************@gmail.comwrote in message
news:11**********************@c35g2000hsg.googlegr oups.com...
>I am trying to execute following code:

Type type = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(type);

and get following RemotingException (in 2-nd line):

Cannot load type SomeType.SomeClass, SomeType.SomeClass,
Version=1.0.2658.25296, Culture=neutral, PublicKeyToken=null

There is no other info why it breaks. I can't figure out what is going
wrong.
SomeType.SomeClass is installed as a COM+ component. I checked "type"
for null and it's not null.
Any help would be appreciated.
Apr 30 '07 #4
"Slavan" <vy*****************@gmail.comwrote in message
news:11**********************@c35g2000hsg.googlegr oups.com...
>I am trying to execute following code:

Type type = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(type);

and get following RemotingException (in 2-nd line):

Cannot load type SomeType.SomeClass, SomeType.SomeClass,
Version=1.0.2658.25296, Culture=neutral, PublicKeyToken=null

There is no other info why it breaks. I can't figure out what is going
wrong.
SomeType.SomeClass is installed as a COM+ component. I checked "type"
for null and it's not null.
Any help would be appreciated.


You need to install the library in the GAC by running gacutil /i <yourdll>

Willy.

Apr 30 '07 #5
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:eV**************@TK2MSFTNGP03.phx.gbl...
Slavan,

Is SomeType.SomeClass a .NET component? If so, you need to have a
reference to the original assembly and create the type using the new
keyword. .NET components hosted in COM+ can not be created in .NET
through COM interop (which is essentially what you are trying to do, if
this is the case).

Hope this helps.
No, this is not true.
You can register a .NET component in the COM+ catalog and call it from
managed code as well as from native COM code.
What the OP it trying to do is create an instance of a .NET class using late
binding, no COM interop is involved here. When creating an instance from
native COM clients, then you effective create this instance through COM
interop.

Willy.
Willy.
Apr 30 '07 #6
On Apr 30, 4:10 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.comwrote in
messagenews:eV**************@TK2MSFTNGP03.phx.gbl. ..
Slavan,
Is SomeType.SomeClass a .NET component? If so, you need to have a
reference to the original assembly and create the type using the new
keyword. .NET components hosted in COM+ can not be created in .NET
through COM interop (which is essentially what you are trying to do, if
this is the case).
Hope this helps.

No, this is not true.
You can register a .NET component in the COM+ catalog and call it from
managed code as well as from native COM code.
What the OP it trying to do is create an instance of a .NET class using late
binding, no COM interop is involved here. When creating an instance from
native COM clients, then you effective create this instance through COM
interop.

Willy.

Willy.
Could you provide code example on how to call COM+ component from .NET
client?

Apr 30 '07 #7
"Slavan" <vy*****************@gmail.comwrote in message
news:11**********************@y5g2000hsa.googlegro ups.com...
On Apr 30, 4:10 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
>"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.comwrote
in
messagenews:eV**************@TK2MSFTNGP03.phx.gbl ...
Slavan,
Is SomeType.SomeClass a .NET component? If so, you need to have a
reference to the original assembly and create the type using the new
keyword. .NET components hosted in COM+ can not be created in .NET
through COM interop (which is essentially what you are trying to do, if
this is the case).
Hope this helps.

No, this is not true.
You can register a .NET component in the COM+ catalog and call it from
managed code as well as from native COM code.
What the OP it trying to do is create an instance of a .NET class using
late
binding, no COM interop is involved here. When creating an instance from
native COM clients, then you effective create this instance through COM
interop.

Willy.

Willy.

Could you provide code example on how to call COM+ component from .NET
client?


It depends on how you would like to call the component, you can use early
binding as well as late binding.

Using late binding , you need to use reflection like this:
// say you have a method like....
public void SomeMethod(string message)
....

then your client can call it like this...
....
t = Type.GetTypeFromProgID("SomeType.SomeClass", true);
helper = Activator.CreateInstance(t);
// here I call "SomeMethod" passing a string as argument using
reflection.
helper.GetType().InvokeMember("SomeMethod", BindingFlags.Default
| BindingFlags.InvokeMethod, null, helper, new object[] {"Test" });
...

However, it's much better to call it using early binding,

1. Using a common interface assembly
// Interface - common assembly.
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("....................................")]
public interface ISample
{
void SomeMethod(string message);
}

// Sample implementation class (another assembly)
// Class implementing ISample
public class Sample : ServicedComponent, ISample
{
public void SomeMethod(string xx)
{..}
}

Your client simply has to set a reference to the "common Interface"
assembly...
and call the method like this.

ISample sample;

// create instance..
Type t = Type.GetTypeFromProgID("SomeType.SomeClass", true);
object helper = Activator.CreateInstance(t);
sample = helper as ISample;
// Call method
sample.SomeMethod("test");

2. Using a reference to the server library.
Here you can just create an instance of the class using new.
Sample sample = new Sample();
sample.SomeMethod(...).
Willy.

Apr 30 '07 #8

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

Similar topics

14
by: Jay O'Connor | last post by:
Is there a good way to import python files without executing their content? I'm trying some relfection based stuff and I want to be able to import a module dynamically to check it's contents...
2
by: Tony Liu | last post by:
Hi, I want to get the name of the calling function of an executing function, I use the StackTrace class to do this and it seems working. However, does anyone think that there any side effect...
2
by: News VS.NET \( MS ILM \) | last post by:
Please see subject ( use reflection but how ? )
7
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
7
by: clr | last post by:
I like to stamp trace logs with the name of the executing Class and Method. I can get the Class Name using GetType.Name and I can get a list of every Method in the class using...
1
by: John A Grandy | last post by:
somewhere in the .net framework libs , is the following intrinsically supplied 1. class-name & method that called the currently executing code 2. for overriden methods within a...
7
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was...
3
by: shanmukhi | last post by:
hi all, i got a problem with struts. iam unable to find it. i have written an action class, form bean class and a jsp page on submitting form, request is going to action class but it is not...
2
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I am executing an AJAX page method that is a long running task. After starting the first method, I execute a second page method to retrieve the status of the task. It works fine in an empty web...
19
by: sukatoa | last post by:
I have a class file that instantiates an object from a jar file or simply a class file inside the jar file is used as part of the simple program.... When we use the the jar file in JSP, we...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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,...

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.