views:

301

answers:

3

How to include COM components on a published .Net site?

A: 

Can I clarify? It sounds like you want to use client-side activex controls embedded in the html (via <object/>). Is that correct?

This isn't a very safe approach; many browsers / platfroms simply won't work this way. If you know your client is IE/windows, then you can perhaps sign the ocx in a cab, marked with the safe-for-scripting / safe-for-initialization flags. BUT - this is not recommended.

If you want a rich client-side experience, consider Silverlight, or a ClickOnce-deployed smart-client if you need richer access to things like scanners etc.


If you mean server-side, then you probably need to install the components on the server. Registry-free COM might work, but isn't easy to configure. If you don't own the server (i.e. it is hosted for you), then perhaps COM isn't the way to go in the first place...

Marc Gravell
Thanks for help marc but i am not talking about activex controls
Samiksha
A: 

Let me be more specific : i am generating an excel in my code and for that i add a reference of office dll from .net COM components in my site ... this works only till i run code locally... this doesnt work when i publish the site on server. How to add com components for published site?

Samiksha
+2  A: 

Finally i succeeded to solve the issue :

To include the COM component on your published site :

  1. Include the reference of the assembly in you config file of server [Locally it gets added by itself when you add the reference] .
  2. Include the dll in your bin folder
  3. Goto start-->run-->type "DCOMCNFG" OR Goto Controlpanel --> Administrative tools-->Component Services -->computers --> myComputer -->DCOM Config --> Microsoft Excel Application.Right click to get properties dialog. Goto Security tab and customize permissions accordingly.

Note: Remember if you are running on Windows 2003 Server you must use the application pool identity as the account and not the ASPNET account.

• Go to the Start-Run menu item.

• Type in "DCOMCNFG" and hit enter.

• This should load the "Component Services" MMC (you can also load from Administrative Tools - Component Services"

• Expand "Component Services"

• Expand "Computers"

• Expand "My Computer"

• Select the "DCOM Config" item

• Select the "Microsoft Excel Application" item.

• Right click and select Properties

• Select the Security Tab

• Under "Launch and Activation Permissions" select the "Customize" option.

• Click the "Edit" button

• Click the "Add" button to add a new account to the list.

• On the dialog that is displayed click the Locations button(this is because by default your domain will be selected and we need a local account)

• Click the OK button

• On the dialog that is displayed enter "ASPNET" as the account name (make sure location is set to the name of the computer that IIS is on) on Windows XP or if you are running on Windows 2003 Server you must enter the account that the Application Pool is running as, by default "Network Service"

Note: A quicker way on Windows XP is to just enter the computer name and the account so in my case that would be: ccrowe\ASPNET

• Click the OK button

• Now make sure you select the following options for the "ASP.NET Machine Account" or the account that is the application pool identity ( by default Network Service)

o Local Launch : Allow

o Remote Launch : [blank]

o Local Activation : Allow

o Remote Activation : [blank]

• Click the OK button and test your web application again and it should work fine.

Samiksha