performance using com dll witdh c#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have imported my com dll with Visual studios "Add reference", and then i'm
using this code:

private static MyComDll connectionKit = new MyComDll();

public static void CreateBatch(object hBatch)
{ ...
connectionKit.ComCreateBatch(...)
}

public static void SendBatch(object hBatch)
{ ...
connectionKit.SendBatch(...)
}

I have no problem with my application, however i think the performance could
be better. Is there any better way to call methods in a com dll? I don't have
access to sourcecode for the dll-file.
 
Jesper,

What do you mean call methods in a COM dll? You are calling methods on
an object that is a wrapper to the type in a COM server. That's about as
good as you are going to be able to get, since COM interop requires a good
number of operations for each call (I think the average is somewhere around
40).

Hope this helps.
 
I was wondering if a could get better performance if i wrote my own wrapper.
I have seen examples using DllImport(), but I'm uncertain what to use. What
do you mean with COM interop requires a good number of operations for each
call?

Thanks in advance,
Jesper Nilsson


Nicholas Paldino said:
Jesper,

What do you mean call methods in a COM dll? You are calling methods on
an object that is a wrapper to the type in a COM server. That's about as
good as you are going to be able to get, since COM interop requires a good
number of operations for each call (I think the average is somewhere around
40).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jesper Nilsson said:
Hi,

I have imported my com dll with Visual studios "Add reference", and then
i'm
using this code:

private static MyComDll connectionKit = new MyComDll();

public static void CreateBatch(object hBatch)
{ ...
connectionKit.ComCreateBatch(...)
}

public static void SendBatch(object hBatch)
{ ...
connectionKit.SendBatch(...)
}

I have no problem with my application, however i think the performance
could
be better. Is there any better way to call methods in a com dll? I don't
have
access to sourcecode for the dll-file.
 
Not sure what kind of application you are building, but you must make sure
your COM object is created in a compatible apartment, else you'll waste some
CPU cycles for cross thread/apartment marshaling.

Willy.
 
Jesper,

When the runtime makes the call from the wrapper to your COM object, it
has to run a number of operations to make that call on the native COM
object. The 40 operations I quoted was the number between the call you see
in .NET and the call being made to your COM object.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jesper Nilsson said:
I was wondering if a could get better performance if i wrote my own
wrapper.
I have seen examples using DllImport(), but I'm uncertain what to use.
What
do you mean with COM interop requires a good number of operations for each
call?

Thanks in advance,
Jesper Nilsson


Nicholas Paldino said:
Jesper,

What do you mean call methods in a COM dll? You are calling methods
on
an object that is a wrapper to the type in a COM server. That's about as
good as you are going to be able to get, since COM interop requires a
good
number of operations for each call (I think the average is somewhere
around
40).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

message
Hi,

I have imported my com dll with Visual studios "Add reference", and
then
i'm
using this code:

private static MyComDll connectionKit = new MyComDll();

public static void CreateBatch(object hBatch)
{ ...
connectionKit.ComCreateBatch(...)
}

public static void SendBatch(object hBatch)
{ ...
connectionKit.SendBatch(...)
}

I have no problem with my application, however i think the performance
could
be better. Is there any better way to call methods in a com dll? I
don't
have
access to sourcecode for the dll-file.
 
Back
Top