Connecting Tech Pros Worldwide Help | Site Map

ASP.NET application freezes when COM object is instantiated

Ralf Müller
Guest
 
Posts: n/a
#1: Nov 19 '05
In a WindowsForms application it works just fine. Why not in ASP.NET?

The interop assembly used was in both cases auto-generated by Visual Studio
..NET from the same .dll

The code is exactly the same in WindowsForms and WebForms:

private void button1_Click(object sender, System.EventArgs e) {
ImyCOMObject obj = new myCOMObjectClass(); // ASP.NET freezes here -
WindowsForm works perfectly
ISearchResult res = obj.Search(tbSearch.Text);
int count = res.Count;
for(int i = 0; i < res.Count; i++) {
....
}
}


Scott Allen
Guest
 
Posts: n/a
#2: Nov 19 '05

re: ASP.NET application freezes when COM object is instantiated


Do you know if the COM component uses the STA threading model? If so, you'll
need aspcompt="true" in your @ Page directive to set a compatible apartment
model for the thread executing the aspx page.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/
[color=blue]
> In a WindowsForms application it works just fine. Why not in ASP.NET?
>
> The interop assembly used was in both cases auto-generated by Visual
> Studio ..NET from the same .dll
>
> The code is exactly the same in WindowsForms and WebForms:
>
> private void button1_Click(object sender, System.EventArgs e) {
> ImyCOMObject obj = new myCOMObjectClass(); // ASP.NET freezes
> here -
> WindowsForm works perfectly
> ISearchResult res = obj.Search(tbSearch.Text);
> int count = res.Count;
> for(int i = 0; i < res.Count; i++) {
> ....
> }
> }[/color]


Saravana
Guest
 
Posts: n/a
#3: Nov 19 '05

re: ASP.NET application freezes when COM object is instantiated


You need to set aspcompat=true. For more details about aspcompat, check out
this article
http://www.aspnetfaq.com/default.asp...&SearchString=

--
-Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com



"Ralf Müller" <mueller@julitec.de> wrote in message
news:Op56yrV$EHA.2104@TK2MSFTNGP14.phx.gbl...[color=blue]
> In a WindowsForms application it works just fine. Why not in ASP.NET?
>
> The interop assembly used was in both cases auto-generated by Visual[/color]
Studio[color=blue]
> .NET from the same .dll
>
> The code is exactly the same in WindowsForms and WebForms:
>
> private void button1_Click(object sender, System.EventArgs e) {
> ImyCOMObject obj = new myCOMObjectClass(); // ASP.NET freezes here -
> WindowsForm works perfectly
> ISearchResult res = obj.Search(tbSearch.Text);
> int count = res.Count;
> for(int i = 0; i < res.Count; i++) {
> ....
> }
> }
>
>[/color]


Ralf Müller
Guest
 
Posts: n/a
#4: Nov 19 '05

re: ASP.NET application freezes when COM object is instantiated


Thank you, Saravana and Scott! It works... somehow. And it works even better
since I've found out how to destroy my COM-Object again.
But I've got one weird problem left: The interface "IAdresse" in the interop
library offers a property called "AnsprechpartnerCount" which is of type
int. This property works fine in the WindowsForms application but gives me a
COMException when using it in my WebApplication. Are there any other
differences between COM handling in ASP.NET and Windows Forms I should know
about?

Greetings, Ralf

"Saravana" <saravank@sct.co.in> schrieb im Newsbeitrag
news:#6l8yeY$EHA.2572@tk2msftngp13.phx.gbl...[color=blue]
> You need to set aspcompat=true. For more details about aspcompat, check[/color]
out[color=blue]
> this article
>[/color]
http://www.aspnetfaq.com/default.asp...&SearchString=[color=blue]
>
> --
> -Saravana
> http://dotnetjunkies.com/WebLog/saravana/
> www.ExtremeExperts.com
>
>
>
> "Ralf Müller" <mueller@julitec.de> wrote in message
> news:Op56yrV$EHA.2104@TK2MSFTNGP14.phx.gbl...[color=green]
> > In a WindowsForms application it works just fine. Why not in ASP.NET?
> >
> > The interop assembly used was in both cases auto-generated by Visual[/color]
> Studio[color=green]
> > .NET from the same .dll
> >
> > The code is exactly the same in WindowsForms and WebForms:
> >
> > private void button1_Click(object sender, System.EventArgs e) {
> > ImyCOMObject obj = new myCOMObjectClass(); // ASP.NET freezes[/color][/color]
here -[color=blue][color=green]
> > WindowsForm works perfectly
> > ISearchResult res = obj.Search(tbSearch.Text);
> > int count = res.Count;
> > for(int i = 0; i < res.Count; i++) {
> > ....
> > }
> > }
> >
> >[/color]
>
>[/color]


Closed Thread