473,765 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeated run of COM from .NET gives System.Reflecti on.TargetInvoca tionException

Hi,

I have a C# program (code fragment below), which runs forever, processing
incoming jobs. Part of this program launches a COM object. However, after
a while I get :

System.Reflecti on.TargetInvoca tionException: Exception has been thrown by
the target of an invocation. --->
System.Runtime. InteropServices .COMException (0x80010007): Automation error

Does anyone know what can be causing this problem?

I am running Framework 1.1.4322 SP 1.

Thanks in advance
G

--------------------------------------------- Code Fragment.---------
Actvivity (the argument for this method) is an object containing text
fields.

// --------------------------------------------------------------------
/// <summary>
/// Given the name of a registered COM ActiveX DLL, this method
/// loads it and attempts to run the action therein.
/// </summary>
/// <param name="activeXNa me"></param>
/// <returns></returns>
// --------------------------------------------------------------------
public bool COMRunActiveXDl l(Activity act) {

bool rv = false; // Return value.
string whoAmI =
Service.IN_WHAT + "COMRunActiveXD LL" + this.currentIns tance;

// - The .NET type equivalent to the named COM DLL. -
Type activityType = null;

// - Instance of COM DLL. -
object activityInstanc e = null;

// - Arguments for the call to the method within the COM DLL. -
object[]activityArgumen ts = null;

// - LastError property of active X dll. -
string activityError = "";

try {

if (act != null) {

// -- Create the COM Active X DLL. --
activityType = Type.GetTypeFro mProgID(act.Mod uleName);
activityInstanc e = Activator.Creat eInstance(activ ityType);

// -- Now create the list or arguments for the activity. --
activityArgumen ts = new object[] {act.CaseId, act.StateId,
act.Argument};

// -- Run the activity. --
rv = (bool) activityType.In vokeMember("Act ion",
BindingFlags.In vokeMethod, null,
activityInstanc e, activityArgumen ts);

if (rv == false) {

activityError = (string)
activityType.In vokeMember("Las tError",
BindingFlags.Ge tProperty, null, activityInstanc e, null);
this.lastError = whoAmI + ": COM ActiveX failed. " +
activityError;
this.Logger.Pos tMessage(this.L astError,
SyslogMessageSe verity.SLOG_WAR NING, whoAmI);

} // if (rv...

} // if (act...

} catch (Exception e) {

this.lastError = whoAmI + ": COM ActiveX exception. " +
e.ToString();
this.Logger.Pos tMessage(this.L astError,
SyslogMessageSe verity.SLOG_WAR NING, whoAmI);
rv = false;

} finally {

// -- Tidy up. --
if (activityInstan ce != null) {
try {
while (Marshal.Releas eComObject(acti vityInstance) > 0) {
// -- Do nothing --
}
} catch (Exception marshalE) {
this.Logger.Pos tMessage("Relea seComObject failed : " +
marshalE.ToStri ng(),
SyslogMessageSe verity.SLOG_WAR NING, whoAmI);
} // try/catch...
} // if (activityInstan ce...

activityArgumen ts = null;
activityInstanc e = null;
activityType = null;

System.GC.Colle ct();

} // try/catch...

return rv;

} // public bool COMRunActiveXDl l...

---------------------------------------------
Nov 17 '05 #1
0 1531

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

Similar topics

0
1040
by: Mauro | last post by:
Hi, i'm testing my application on XP and on W2k. On XP it works, but when i try to run my application (after installation) on Windows 2000 i receive this error message: "An Exception 'System.Reflection.TargetInvocationException' has occurred in myApplication.exe" How this is possible? Thx for all.
3
1395
by: rob2 | last post by:
I have written a C# application that runs fine from within the IDE, and also when I invoke it via the Windows 'Run' dialog or from explorer. I am trying to make the app launch automatically when windows starts, and have placed a registry value under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run to run the .exe. This worked for a while, but now I have added some code which performs deserialization of some data as the app...
2
1914
by: Lev | last post by:
Hi, I have some code that does reflection on an assembly I load. When I try to get the attributes on one of the methods implemented in the assembly, the MC++ version does not return anything. See code below: Object __gc* memberAttributes = info->GetCustomAttributes(__typeof(EntryPointAttribute), false);
0
7945
by: chaf2701 | last post by:
Hi, I was in trouble with the System.Windows.Forms.ImageList control from VC.NET. I was doing the following : 1. New Project, C#, Windows Application 2. Add ImageList component imageList1 to Form1 3. in imageList1 properties open the 'Image Collection Editor' for Images and add a simple copy.bmp
3
4355
by: pmud | last post by:
Hi, I have ab ASP.Net Application in which I need to send e-mail on button click. Even though my C# code for that is correct.I am getting the following error:: I think the following error can be bcoz of the SMTP virtual server. I cant view the SMTP virtual server in IIS. How to correct this error??? Send failure: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException:...
4
2664
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am printing these session variables they are printing. After that I am assigning these things in hidden object and in the form submit action I am receiving these hidden values like the following:
0
1695
by: Sutabi | last post by:
I'm trying to compile a "Release" build of a project, and in debug more it compiles and runs fine. In release mode it builds, but does not run and returns this exception. I have no idea what this might mean, can anyone enlighten me? -------------------------------- Exception System.Reflection.TargetInvocationException was thrown in debugee: Exception has been thrown by the target of an invocation.
0
3382
by: Amelyan | last post by:
Why does this happen? How to fix it? Once in a while I get error in ~/ScriptResource.axd?d=... System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at
2
11019
by: =?Utf-8?B?c2FtMDFt?= | last post by:
I have a remoting application that was developed on a Windows XP SP2 machine with VS2005 SP1. I finally got everything deployed using Wix 3.0, and it works great. Problem is, when I install the msi on a W23 server SP2, I get the following error: System.Runtime.Remoting.RemotingException: Remoting configuration failed with the exception 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation....
0
9568
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
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9959
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,...
0
8833
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
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
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3926
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
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.