Hi there,
I need to use an ActiveX inside a Web service. My problem is that I need an
handle on this Com component, so I add a reference to my .Net project, and I
create an instance of class of this Com exe. But I then realize that each
time I call for a method of my web service, I create a new Com exe process,
which is not what I want.
Any idea to avoid this pitfall ?
Philippe 4 3409
HI,
I don't know much of com... but still want to share the thought
can't you load the componet in application start in global.ascx
and the share the same component in all the request...
regards
Munna
Hi Philippe ,
For your scenario, since you're calling an out-of-process COM object, it
will launch new COM process for new created object. To avoid this, I agree
with Munna that you can use a global variable(such as a static class
member) to cache a single instance of the COM component instance(someth ing
like a singleton wrapper class) and all your webservice methods will use
that one. There is several things you need to take care here:
1. The COM component might not be thread safe, so for such multi-threading
environment, you will need to lock it when accessing it in each thread.
2. If #1 will make your performance impacted, consider creating multiple
such global instances as a pool so that you can always reuse these pooled
instances.
3. for .NET webservice/web application environment, the thread is MTA
thread while most COM objects are STA, this will make an additional calling
gap between them. If the COM is really an STA one, you may need to adjust
your webservice thread's COM apartment model, see the following article:
#Running ASMX Web Services on STA Threads http://msdn.microsoft.com/en-us/magazine/cc163544.aspx
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Oriane" <or****@noemail .noemail> Subject: Using an ActiveX in a Web service Date: Thu, 24 Jul 2008 18:26:08 +0200
> Hi there,
I need to use an ActiveX inside a Web service. My problem is that I need
an
>handle on this Com component, so I add a reference to my .Net project, and
I
>create an instance of class of this Com exe. But I then realize that each time I call for a method of my web service, I create a new Com exe
process,
>which is not what I want.
Any idea to avoid this pitfall ?
Philippe
Hi Steven,
"Steven Cheng [MSFT]" <st*****@online .microsoft.coma écrit dans le message
de news:Gr******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Philippe ,
For your scenario, since you're calling an out-of-process COM object, it
will launch new COM process for new created object. To avoid this, I
agree
with Munna that you can use a global variable(such as a static class
member) to cache a single instance of the COM component instance(someth ing
like a singleton wrapper class) and all your webservice methods will use
that one. There is several things you need to take care here:
1. The COM component might not be thread safe, so for such multi-threading
environment, you will need to lock it when accessing it in each thread.
I need to check...
2. If #1 will make your performance impacted, consider creating multiple
such global instances as a pool so that you can always reuse these pooled
instances.
Good point.
3. for .NET webservice/web application environment, the thread is MTA
thread while most COM objects are STA, this will make an additional
calling
gap between them. If the COM is really an STA one, you may need to adjust
your webservice thread's COM apartment model,[...]
Up to now I've got no problem.
So I 've added the a Global.asax file and I create the COM component in the
Application_Sta rt as a static variable. I've also added these lines on the
Application_End method:
protected void Application_End (object sender, EventArgs e)
{
// Destroy any reference
System.Runtime. InteropServices .Marshal.Releas eComObject(Stib ilCtl);
StibilCtl = null;
}
and I think that you and Muna (which I thank also here) are absolutely
right, since now I've got only one COM object created (perhaps I will need a
pool later as yous suggest). I also have to check if I need to lock the
accesses to this object.
Thanks again
Oriane
Thanks for your followup Oriane,
Sure, if you have any further questions on this later, please feel free to
post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsof t.com.
=============== =============== =============== =====
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Oriane" <or****@noemail .noemail> References: <4D************ *************** *******@microso ft.com>
<Gr************ **@TK2MSFTNGHUB 02.phx.gbl>
>In-Reply-To: <Gr************ **@TK2MSFTNGHUB 02.phx.gbl> Subject: Re: Using an ActiveX in a Web service Date: Mon, 28 Jul 2008 08:59:49 +0200
> Hi Steven, "Steven Cheng [MSFT]" <st*****@online .microsoft.coma écrit dans le
message
>de news:Gr******** ******@TK2MSFTN GHUB02.phx.gbl. ..
>Hi Philippe ,
For your scenario, since you're calling an out-of-process COM object, it will launch new COM process for new created object. To avoid this, I agree with Munna that you can use a global variable(such as a static class member) to cache a single instance of the COM component
instance(someth ing
>like a singleton wrapper class) and all your webservice methods will use that one. There is several things you need to take care here:
1. The COM component might not be thread safe, so for such
multi-threading
>environment, you will need to lock it when accessing it in each thread.
I need to check...
>2. If #1 will make your performance impacted, consider creating multiple such global instances as a pool so that you can always reuse these pooled instances.
Good point.
>3. for .NET webservice/web application environment, the thread is MTA thread while most COM objects are STA, this will make an additional calling gap between them. If the COM is really an STA one, you may need to adjust your webservice thread's COM apartment model,[...]
Up to now I've got no problem.
So I 've added the a Global.asax file and I create the COM component in the Application_St art as a static variable. I've also added these lines on the Application_En d method:
protected void Application_End (object sender, EventArgs e)
{
// Destroy any reference
System.Runtime. InteropServices .Marshal.Releas eComObject(Stib ilCtl);
StibilCtl = null;
}
and I think that you and Muna (which I thank also here) are absolutely right, since now I've got only one COM object created (perhaps I will need
a
>pool later as yous suggest). I also have to check if I need to lock the accesses to this object.
Thanks again
Oriane
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David |
last post by:
Hi everyone,
I have a ActiveX EXE component written in VB6. This ActiveX EXE exposes
various public methods that can be called by several other independent
Windows EXE applications (also written in VB6).
I would like to port the ActiveX EXE component it to dotNet. What type of
project that I should port it to? A Windows Service or what? Please suggest.
The thing is that I will not be porting the existing Windows EXE
|
by: andy.g.ward |
last post by:
I keep getting this when trying to create an MFC activex control in a
c# windows service - anyone got any ideas what the missing module could
be???
Exception thrown : System.IO.FileNotFoundException: The specified
module could not be found.
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid&
clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense()
at...
|
by: Jay A. Moritz |
last post by:
I have an application that loads IE and iterates through web pages to
retrieve information from the page then activates specific controls to
retrieve the next page and iterate through that page for it's information,
etc, etc.
I have found many articles from people getting COMException errors when
trying to use Interop.SHDocVw from a windows service, so it's pretty
apparent to me that this is a difficult application to build, but I have...
|
by: las |
last post by:
(Originally posted to framework.aspnet.webservices, but I am casting a
larger net and trying again)
I am using a library supplied by a third-party vendor. Although the
library has no UI, the vendor supplies it as an .OCX control.
I need to utilize this library in an ASP.Net Web Service. My Web
Service does not expose the OCX control's functionality directly, but
utilizes the OCX for its own internal purposes.
|
by: Bob |
last post by:
I need to code a service which accepts latitude and longitude coordinates and
returns the nearest place name. It will accept the coordinates from an MSMQ
and return the placename on another. A Windows Service would be indicated but
can't be used because the actual location functions used are part of an
ActiveX Form control. The service will have no UI. I have the thing working
as an EXE where the control is hosted by a form which is never...
| |
by: Artie |
last post by:
Hi,
Our team have a web project which includes some C# ActiveX DLLs.
On some developers' PCs, the code which calls methods in the ActiveX
dll is succesful - no exceptions. On other PCs, the ActiveX control
doesn't even seem to get loaded. (On the failing machines, if we try
and debug down to where the ActiveX DLL method is invoked, both Visual
Studio
and IE hang.)
|
by: Jialiang Ge [MSFT] |
last post by:
Hello Philippe,
In addition to bruce's points, I'd suggest the KB article
http://support.microsoft.com/kb/317392. It demonstrates how to host an
ActiveX control in ASP.NET (for your first question), and points out that
ActiveX control is a pure client-side control, the server-side code cannot
access this control (for your second question). Server-side code can access
only server controls, which are the controls that are listed on the Web...
|
by: tuvman |
last post by:
We are developing a web application. Our web app is a heavy client-
our existing .net app exposed as an activex control running in IE. We
need the activex to be able to access our remote database server when
hosted within a browser from anywhere.Originally we were planning on
using port forwarding...and having the externalip:databaseport forward
from the web server to the database server. But our customer's network
admin says this is not...
|
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= |
last post by:
I have a asp.net app, in the page there is a scan activex which could scan
and save a jpg file in client harddisk.
How could we access and display this jpg file on the fly using js in the
client IE?
Thanks,
-Billy zhang
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |