Using ATL COM DLL in Web-Based application (Visaul C# and ASP.NET)

G

Guest

Hi All,

My requirement: I want to use TestDll.dll(ATL COM DLL, Threading Model -
Apartment, Interface - Dual and Aggregation - Yes) in ASPX pages.

I created type library for TestDll.dll (ATL COM DLL) using tlbimp
from VS2005 command prompt. Output is TESTDLLLib.lib(.NET Assembly). It has
only one function which is CreateFileInCDrive(). It just creates one text
file in C
Drive.
code snippet:
STDMETHODIMP CMyTest::CreateFileInCDrive()
{
// TODO: Add your implementation code here
FILE* fp = fopen("C:\\TestDll.txt","w");
if (fp != NULL)
{
fprintf(fp,"%s","welcome\n");
fclose(fp);
}

return S_OK;
}

I created asp.net website project and selected code behind as visual c#. I
would like to use atl com dll (TestDll.dll) in Page_Load event. Is it
possible?

In Visual C#, (i mean page_load function) I am able to create object.
But, I cannot create the TestDll.txt file.

I can use this TESTDLLLib.lib in Visual C# Console application. But, it is
now working fine in asp.net with visual C# application. What might be the
problem?

Please suggest me.

Is it correct approach?
 
P

Petar Atanasov

John said:
Hi All,

My requirement: I want to use TestDll.dll(ATL COM DLL, Threading Model -
Apartment, Interface - Dual and Aggregation - Yes) in ASPX pages.

I created type library for TestDll.dll (ATL COM DLL) using tlbimp
from VS2005 command prompt. Output is TESTDLLLib.lib(.NET Assembly). It has
only one function which is CreateFileInCDrive(). It just creates one text
file in C
Drive.
code snippet:
STDMETHODIMP CMyTest::CreateFileInCDrive()
{
// TODO: Add your implementation code here
FILE* fp = fopen("C:\\TestDll.txt","w");
if (fp != NULL)
{
fprintf(fp,"%s","welcome\n");
fclose(fp);
}

return S_OK;
}

I created asp.net website project and selected code behind as visual c#. I
would like to use atl com dll (TestDll.dll) in Page_Load event. Is it
possible?

In Visual C#, (i mean page_load function) I am able to create object.
But, I cannot create the TestDll.txt file.

I can use this TESTDLLLib.lib in Visual C# Console application. But, it is
now working fine in asp.net with visual C# application. What might be the
problem?

Please suggest me.

Is it correct approach?

Sounds like something trivial - write permission for the web app or
something like this. By the way - why didn't you do the standard
approach - with [DllImport("TestDll.dll")] + wrapper function and etc...

HTH
Petar,
http://a-wake.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top