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

Calling old C DLL for ASP.NET Web Service

Hi,

I need to call an old C DLL from my Web Service. This in itself is
fine and I am able to do this no problem. My issue is that I need to
call the DLL thousands of times, and it has memory leak and memory
corruption problems, so after a while it dies with a memory corruption
error. I donot have the option of fixing the memory leak, so I need
to come up with a solution.

my understanding is is the once an external dll is imported into the
ASP worker process using the dllimport command that it cannot be fully
unloaded and released (I've tried lots of examples on the net, even
calling Win32 API calls to unload the DLL).

My proposed solution is the wrap the calls to the dodgy C dll in an
out of process application written in VB6 (ActiveX EXE). As the code
will be running outside of the ASP worker process, I can then easily
release the COM object and will not have the dodgy memory corruption
in my ASP.NET app.

I know this solution will probably slow things down a hell of a lot,
but it will work ? The only option I have at the moment is to restart
IIS when the old dll goes bang.

Has anyone used this technique before, and is my proposed solutino
viable ?

Cheers
Jun 27 '08 #1
7 1506
Have you tried creating a wrapper for the DLL with TLBIMP.exe?

TLBIMP ComponentName.dll /out:NewName.dll

That will create a .Net assembly from your C DLL.

There are exceptions (some DLL functions can't be imported into a wrapper assembly),
but for the most part TLBIMP can do the job. Try it and see.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<ma**************@gmail.comwrote in message news:ef**********************************@34g2000h sf.googlegroups.com...
Hi,

I need to call an old C DLL from my Web Service. This in itself is
fine and I am able to do this no problem. My issue is that I need to
call the DLL thousands of times, and it has memory leak and memory
corruption problems, so after a while it dies with a memory corruption
error. I donot have the option of fixing the memory leak, so I need
to come up with a solution.

my understanding is is the once an external dll is imported into the
ASP worker process using the dllimport command that it cannot be fully
unloaded and released (I've tried lots of examples on the net, even
calling Win32 API calls to unload the DLL).

My proposed solution is the wrap the calls to the dodgy C dll in an
out of process application written in VB6 (ActiveX EXE). As the code
will be running outside of the ASP worker process, I can then easily
release the COM object and will not have the dodgy memory corruption
in my ASP.NET app.

I know this solution will probably slow things down a hell of a lot,
but it will work ? The only option I have at the moment is to restart
IIS when the old dll goes bang.

Has anyone used this technique before, and is my proposed solutino
viable ?

Cheers

Jun 27 '08 #2
Thanks for the response I'll give it a go and let you know how I got
on.

Cheers
Jun 27 '08 #3
It won't work for me. TLBIMP converts the type definitions found
within a COM type library into equivalent definitions in a common
language runtime assembly.

My C DLL is not a COM dll. :(
Jun 27 '08 #4
<ma**************@gmail.comwrote in message
news:ef**********************************@34g2000h sf.googlegroups.com...
Has anyone used this technique before,
Yes, but had to abandon it as performance degradation was unacceptable...
and is my proposed solution viable ?
Technically, yes. Practically, depends on how slow it actually is in the
real world...

I'm presuming that you no longer have the source code for the DLL...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #5
re:
!It won't work for me.
!My C DLL is not a COM dll

Drats!
It was worth a shot anyway. Sorry for not having been able to help more.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
<ma**************@gmail.comwrote in message news:16**********************************@59g2000h sb.googlegroups.com...
It won't work for me. TLBIMP converts the type definitions found
within a COM type library into equivalent definitions in a common
language runtime assembly.

My C DLL is not a COM dll. :(

Jun 27 '08 #6
Hi Mark,

No I don't have acesss to the old C code, so trying to fix the leak
is'nt viable.

Good to hear that technically what I am trying to achieve is possible.

One thing that is important though is performance, so the fact that
you had to abandon the venture because of performance problems might
mean that what I am trying to do might not be a sutiable solution. I
will give it a go though.

One other thing to mention, I stated originally that I need to call
the C DLL thousands of times. The C DLL is not thread safe (It's not
a great DLL :) ), however, as it will now be runnning in its own
process. I am considering using the thread pool to call it lots of
times on seperate threads. Each thread will affectively will create a
seperate process to call my C DLL. I will then get each thread to
release the out of process server when finished.

I am hoping that the speed benefits I can use by utilising multiple
threads will offset any perfomance degradation caused by created the
out of process server.

The web server I am using for the app is brand new and a decent spec
so it should be able to handle this without to much stress.
Jun 27 '08 #7
<ma**************@gmail.comwrote in message
news:9d**********************************@m73g2000 hsh.googlegroups.com...
No I don't have acesss to the old C code, so trying to fix the leak
is'nt viable.
That's a shame. How large / complex is the C DLL? Do you still have the
specs / documentation for it...?
Good to hear that technically what I am trying to achieve is possible.

One thing that is important though is performance, so the fact that
you had to abandon the venture because of performance problems might
mean that what I am trying to do might not be a sutiable solution. I
will give it a go though.
I will be very surprised if you can get it to perform at an acceptable
speed...
One other thing to mention, I stated originally that I need to call
the C DLL thousands of times. The C DLL is not thread safe (It's not
a great DLL :) ), however, as it will now be runnning in its own
process. I am considering using the thread pool to call it lots of
times on seperate threads. Each thread will affectively will create a
seperate process to call my C DLL. I will then get each thread to
release the out of process server when finished.

I am hoping that the speed benefits I can use by utilising multiple
threads will offset any perfomance degradation caused by created the
out of process server.
The web server I am using for the app is brand new and a decent spec
so it should be able to handle this without to much stress.



--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #8

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

Similar topics

4
by: jarmopy | last post by:
Hi, I have made a service with C# and calling that service class from another C# program with remoting. (Referendes from the calling program) That service class is configured so that garpage...
0
by: Cleo | last post by:
Hi, I am trying to call a WebService Method written in Weblogic from VB.NET and I am getting the following error. I am using SOAP Caal s from VB.NET. Please find the wsdl file and my code. ...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
7
by: Stu | last post by:
Hi, I have a web service which returns a record set and works well integrated with an asp dot net page. However if I decided to develop a unix app will i be able to read the dataset as it is...
5
by: joeblast | last post by:
I have a Web service that gets the financial periods and hold a reference to a disconnected dataset built at initialization. Web methods work on the dataset inside the web service. Everything is...
1
by: fallenidol | last post by:
hi i'm looking for some heads up info regarding calling and using a web service from within another web service. is this acceptable practice? if not why? what should i be thinking about here? ...
2
by: Johan | last post by:
We have run into problems calling a web service from a client running .NET framework 2.0. The problem is that the first call to the web service, after the client has been started, takes very long...
1
by: ananth | last post by:
Hi All, I have a web service created in Notes Database and i am calling the web service in Visual studio.Net application by adding a web reference. I need to have authentication...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.