473,388 Members | 1,375 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,388 software developers and data experts.

Activator.CreateInstance(Type)

We have a remote server application called from a client application.

The server application is a .NET application but built with COM supportability and included as a COM+ service on one system. The client application, which is also written in .NET calls the COM+ application remotely(from one or more different machines) The invocation of the remote object is done by the call below

Type oType = Type.GetTypeFromProgID("<Program ID>", "<Server Name>")
Activator.CreateInstance(oType ) as ...


After I get the functionality from the remote application, I try to close this instance thus created by

Marshal.ReleaseComObject (oSrvProxy)


Now I get the exception "MSCORLIB specified cast is not valid." I think the problem is because our server object is not a __ComObject or derived from a __ComObject. It is a CLR object. However, for the .NET 1.1 framework, we have observed that when the client application is killed, the server application memory is released too. In .NET framework 2.0, we noticed that it gives an exception when the client application is closed.

Now coming to our problem
1. As the objects are in memory and will be removed only when the application closes and if the connection is terminated, then the object stays in the server memory till the server application is restarted. We need to explicitly release this server object so that the server object is cleared from the server memory after the time that is set for the object to be alive (time for idle shutdown), explicitly, rather than at the client application closure
2. The change in behavior of .NET framwork 2.0 raises exception at the closure of the client application.

Now coming to my questions
1. Instead of building the .NET server application as a COM+ application and using it as a COM+ server application for .NET clients, isn't there a better way to design to use the functionalities of the remote server application? What do you suggest?
2. Is there any means by which I can programmatically release the server object from the client other than at the application closure? As I mentioned before, Marshal.ReleaseComObject() is of no use.

Thanks a lot for your valuable time. If you need me to post this in thescripts, i can also do that.

Thanks and warm regards,
- Midhun George.
May 17 '07 #1
0 1319

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: shmeian | last post by:
I have the following code which works fine. However I want to pass the object I'm instantiating a string for its constructor. I can't get the syntax right. Can someone give me an example of...
3
by: boxim | last post by:
Hi all, Real easy one I think, just can't find example, I need to create an instance of a type, but i don't have a type var, i have a string e.g. string t = "MyNamespace.Class1"; I wan't...
2
by: Frank Pleyer via .NET 247 | last post by:
Hi, I got the following problem : I have an defined an Array of different Actions: public PRootActions AllActions = new PRootActions ; I got a dynamic method where all Actions or other...
3
by: Doug Riley | last post by:
I am using CreateInstance to create an instance of a class and invoke a function of that class. I really need it to execute in a single line of code (long story, but I want to execute this code in...
1
by: Nancy Sui | last post by:
I am trying to dynamically load a dll which specifies different rules for evalution with the following code. DataRow dr = ds.Tables.Rows; string fileName = Convert.ToString(dr); assemblyInstance...
10
by: Chris Morse | last post by:
Hi, I'm trying to figure out how to dynamically load an assembly and get an IClientPlugin interface to a class. I can get an "Object" reference to it after doing an "Activator.CreateInstance"...
1
by: Ryan.Mohammed | last post by:
I have a problem that does not happen without .NET 1.1 however it does happen on machines that have .NET 1.1 SP1 installed. Createinstance attempts to create an instance of ICEBOX.dll which...
1
by: Johnny R | last post by:
Hello, I'm loading a Class from Assemly DLL using Activator.CreateInstance. That loaded Class is executed in a worker Thread with no loop. What actually happends when class is loaded using...
5
by: not_a_commie | last post by:
It seems that the only way to construct a struct from a type is to use Activator.CreateInstance. Is that true? Can anyone improve (performance-wise) upon this function below: /// <summary>...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
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.