I created a control library by adding refrence to office interop excel to do some excel automation in client.The control works fine in windows forms Now i need to add the control in asp.net can somebody tell how to do that.
a windows class library will work just fine in asp.net. however, if you make a windows from control (or user control, etc) the control (etc.) will NOT work in asp.net.
all you have to do is add a reference to the assembly in your project. If your assembly references other assemblies, you will probably have to reference those in your project as well. As long as you do not attempt to create instances of controls that have a informs UI, you should be OK.
You cannot use Office Interop in an ASP.NET application, or any other server-based application. Please see Considerations for server-side Automation of Office, and please don't try it.
Related
I'm using Visual Studio 2015. I have successfully created a class library and selected:
Register form COM Interop
Make Assembly COM-visible
I've then managed to deploy this using a Setup Project to other users and it works great (although still don't understand why Intellisense doesn't work for it)
Now I'm trying to do the same for a WinForms application, but
Register form COM Interop
is not viable to apply, it's grayed out - should it be? And if so, why can't I register an application for COM Interop so I can manipulate it in other apps? (e.g. in Excel VBA)
The problem is that com registration normally makes only sense for assemblies (.dlls) and your WinForm application is normally a executable (.exe).
So I this case you should create a dll and move all the functions and classes that should be com visible into this assembly. Than make it Com visible and use it also from your executbale WinForms application.
To register a .NET assembly for COM Interop, the assembly has to be a class library, which is intended to be shared by applications.
A WinForms application, on the other hand, runs as a standalone program is not intended to be shared by other applications.
In this case, you can create a class library project, and creates a WinForms UserControl in the project, and expose the UserControl to other apps by making it COM visible.
Here is an old example, strangely it is hard to find more recent examples in my search.
Is it possible to create an VSTO add in for multible office applications?
Can I outsource the functions i want to have for every application and then create an Add-in for every application? If yes, is there a better way to achieve this?
I recommend making a solution with an add-in project for each Office application.
Then add a class library project to the solution and reference that from each of the add-on projects.
That way you can centralize code used in all add-ins.
If you need to interact with the active application or document, you can detect the type of the calling object and typecast it to the relevant application/document type.
Yes - you can just put your common functions into a shared DLL, just like any other application. Since each VSTO project targets a different application structure and potentially UI paradigm, I'd recommend having different VSTO projects in a single solution, and a shared assembly holding the common code.
VSTO doesn't support creating multi-host add-ins. You need to create separate projects for each host and use a class library for the shared code base.
Note, Add-in Express allows creating multi-host COM add-ins. So, a single add-in project can be run in multiple hosts. It comes from the IDTExtensibility2 interface. I don't know why VSTO creators didn't provide such feature to developers.
VSTO itself doesn't provide such an option. If you want to get single project for all application you can use shim add-in. That makes possible to run add-in in all applications from the same dll. The only issue -- your code need to handle what application started to call it to run separate logic or to call specific office API functions.
I have working web page, that uses ActiveX control
ActiveX control was developed by previous programmer (he is out of reach now)
I did some changes in ActiveX control source code and now I need to somehow change current ActiveX control for my changed.
So my question is
Q: How to change old ActiveX control for new one on server.
Thanks in advance for any help you are able to provide.
If the existing ActiveX is in written in C++ and visual studio, then simply follow the following steps:
Make the required changes in the source code.
Build the upgraded ActiveX control using the F5 key on the Visual
Studio.
Copy the ActiveX to the server and manually register by writing the
following code in the cmd with admin rights. * regsvr32
"location of your ActiveX control"
Now you can use your updated ActiveX control either in IE or any other supported container.
I have a WPF dll with a user control. It works just fine when I use it in a WPF project as a reference.
I needed to test in a mixed environment. So I created a Windows Forms solution, added the reference to both the WPF dll and the WindowsFormsIntegration dll. I placed an ElementHost in the form.
In the code behind, I called using on the WPF user control namespace, created an object of the user control and assigned it as the child of the ElementHost. Till this point, intellisense also seemed to work fine. The moment I built the project, however, I got a build error saying that the WPF namespace that I had used was not found.
All dlls are built in .NET 3.5 and the client solution is also in .NET 3.5. Is this a known issue? What could be off with this scenario?
Can you please follow the following link to check whether you have referred all the dll's which is necessary to run WPF custom control in Winform
http://msdn.microsoft.com/en-us/library/ms742215.aspx.
I am currently porting a legacy VBA application to a .Net application. During this process the users of the existing VBA application need to have some features added. So instead of coding them in VBA & then later in C#, I’ve wrote the new functionality in C# and I want to expose this to the existing VBA application through COM, as well as also keeping it in the currently .Net application version.
The solution contain several projects, 1 project for the UI, 1 project for Business Logic, 1 project for the data access layer.
The new features are just a some new forms to modify data. So ideally they will click on a form command button in access which lunch these C# forms via COM interop.
How should I go about exposing this forms through COM Interop.
What I was hoping to do was just add another project, MyProject.COM, which will contain my Interface ICOMManager, for exposing methods to access to launch the required forms. My COMManager class will just instantiate the required forms in my .net application and show them.
This project MyProject.COM will have references to the UI layer & Business Logic Layers.
When I want to register this project using REGASM how will I include references to these other projects?
Thanks for any help or advice on how about doing this.
Ah ok so i see this is alot easier than i thought.
Once i looked at the reg file produced by regasm i could see that the tlb (Type Library) is just a pointer to where it can find the libraries to execute the .Net component.
So once i register the tlb and make sure its pointed to the install directory where the rest of the project files are located it works.