Ask a Question related to ASP.NET Web Services, Design and Development.
-
Alfred B. Thordarson #1
DllImport and WebMethod and STAThread
I'm trying to use a 3rd party DLL, which I have no control over, in my
WebService (written in C#). However, every time my WebService tries to
call one of the dllimport-ed methods it simply never returns from the
call. I know the DLL is there and it works well in many console and
windows applications I have done.
I have been able to create a console application that fails in the
same way, at least I think it does!?!? It fails if I take the
[STAThread] from the main method. Then I get a message dialog saying
"The operating system cannot load the DLL module. Please check that
the DLL module exists, and that any other DLL modules that it will use
also exist." The DLL is there and it works if I put the [STAThread]
back on the main method.
How do I make part of my WebService use the STAThread model instead of
the multi-threaded model? I realize I don't want to do this all over,
just partially?!?!
I have seen some discussions about using dllimport and WebServices
together but nothing that can help me. All your help is highly
appreciated.
Looking forward to hearing from you.
Thanks.
Alfred B. Thordarson Guest
-
dllimport and web services
I have an C#/ASP.Net 1.1 Web Service that has an exposed Web Method that uses an unmanaged DLL via the DllImport Attribute. Is one copy of the DLL... -
DllImport to unmanaged
Hello NG From a Web Project (C#, XP-box) I want to call unmanaged code : so private static extern int FirstFunc(); BUT when I in my... -
DllImport Error
Hello friends, I need to load an unmanaged dll(which i wrote for license control) from system32 folder and then my asp. net project will read the... -
dllimport call in aspnet application makes the application hangs
As our application design requires us to use one of the validation API engine which was written on C(so basically all I have is a dll) and I tested... -
cant add another webmethod :(
Hello I have this code: <%@ WebService language="VB" class="TCPUtil" %> Imports System Imports System.Web.Services Imports... -
Alfred B. Thordarson #2
Re: DllImport and WebMethod and STAThread
I was able to call the dllimport-ed methods, in a webservice, by
creating a new thread, changing it's ApartmentState into STA, and then
have it run my dllimport-ed methods. This is a major hassle if I have
many different methods with different parameters. Is there really no
other way to do this?
--snippet:
Thread staThread=new Thread(new
ThreadStart(newHandler.STAAppendRecordsetXml));
staThread.ApartmentState=ApartmentState.STA;
staThread.Start();
There must be a better way?
-Alfred
[email]athordarson@landsteinar.je[/email] (Alfred B. Thordarson) wrote in message news:<79fc7025.0312011153.63456edd@posting.google. com>...> I'm trying to use a 3rd party DLL, which I have no control over, in my
> WebService (written in C#). However, every time my WebService tries to
> call one of the dllimport-ed methods it simply never returns from the
> call. I know the DLL is there and it works well in many console and
> windows applications I have done.
>
> I have been able to create a console application that fails in the
> same way, at least I think it does!?!? It fails if I take the
> [STAThread] from the main method. Then I get a message dialog saying
> "The operating system cannot load the DLL module. Please check that
> the DLL module exists, and that any other DLL modules that it will use
> also exist." The DLL is there and it works if I put the [STAThread]
> back on the main method.
>
> How do I make part of my WebService use the STAThread model instead of
> the multi-threaded model? I realize I don't want to do this all over,
> just partially?!?!
>
> I have seen some discussions about using dllimport and WebServices
> together but nothing that can help me. All your help is highly
> appreciated.
>
> Looking forward to hearing from you.
>
> Thanks.Alfred B. Thordarson Guest



Reply With Quote

