473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Programmatically Add Reference Com Component into C# Project?

Hi,

I am developing a project which uses "Microsoft Word Interop". There may be
a case in which the end-user may not have Microsoft Office or Office
Interops. So i do not want to add a com reference into my project from the
Solution Explorer by right-click "Add reference". I do want to add com
reference when the user loads the page that is going to show a "Microsoft
Word" document. In this case, while the page is loading, i can check that
the user has the interops or not. If not, i am going to show a message box
including the error message.

Programmatically adding com refernce is possible?or not? Thanks...
Nov 17 '05 #1
6 8243
Adding a reference is only relevant at compile time. It is so your code can
compile. Adding references is a visual studio concept, not deployment.

Either your code can compile, or it can't. By the time the end user gets
it, it's already compiled.

After deployment, if your DLL needs a particular component, and can't find
it, then it's too late, and you get an error.

"Adam Right" <ad**@right.com> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl...
Hi,

I am developing a project which uses "Microsoft Word Interop". There may
be a case in which the end-user may not have Microsoft Office or Office
Interops. So i do not want to add a com reference into my project from the
Solution Explorer by right-click "Add reference". I do want to add com
reference when the user loads the page that is going to show a "Microsoft
Word" document. In this case, while the page is loading, i can check that
the user has the interops or not. If not, i am going to show a message box
including the error message.

Programmatically adding com refernce is possible?or not? Thanks...

Nov 17 '05 #2
Adding a reference is only relevant at compile time. It is so your code can
compile. Adding references is a visual studio concept, not deployment.

Either your code can compile, or it can't. By the time the end user gets
it, it's already compiled.

After deployment, if your DLL needs a particular component, and can't find
it, then it's too late, and you get an error.

"Adam Right" <ad**@right.com> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl...
Hi,

I am developing a project which uses "Microsoft Word Interop". There may
be a case in which the end-user may not have Microsoft Office or Office
Interops. So i do not want to add a com reference into my project from the
Solution Explorer by right-click "Add reference". I do want to add com
reference when the user loads the page that is going to show a "Microsoft
Word" document. In this case, while the page is loading, i can check that
the user has the interops or not. If not, i am going to show a message box
including the error message.

Programmatically adding com refernce is possible?or not? Thanks...

Nov 17 '05 #3
You could probably use Reflection to bypass the functionality of some
things based on availablily of libraries on an outside users PC.

In my experience Reflection can add some overhead to your applications,
but can be used to make more addaptible to its surroundings.
Pseudo-polymorphic if you will.

Making use of Attributes on your classes will assist in using
Reflection to use different methods in place of ones that may be
missing required resources.

Nov 17 '05 #4
You could probably use Reflection to bypass the functionality of some
things based on availablily of libraries on an outside users PC.

In my experience Reflection can add some overhead to your applications,
but can be used to make more addaptible to its surroundings.
Pseudo-polymorphic if you will.

Making use of Attributes on your classes will assist in using
Reflection to use different methods in place of ones that may be
missing required resources.

Nov 17 '05 #5
Dear Sir,
there is no difference for end user what is added to your project as
reference.
Important is, how the referenced types are resolved at run time. So if user
has no word, then the first fuction, which uses classes from this interop
will throw an exception.
Just catch this exception or don't call this function, if word is not there.
Hope it makes sence. You might want to read in MSDN how types are resolved
(keyword reflection,
AssemblyResolve, ResolveEventHandler ...).

Best regards,
Boni

"Adam Right" <ad**@right.com> schrieb im Newsbeitrag
news:eE**************@TK2MSFTNGP14.phx.gbl...
Hi,

I am developing a project which uses "Microsoft Word Interop". There may
be a case in which the end-user may not have Microsoft Office or Office
Interops. So i do not want to add a com reference into my project from the
Solution Explorer by right-click "Add reference". I do want to add com
reference when the user loads the page that is going to show a "Microsoft
Word" document. In this case, while the page is loading, i can check that
the user has the interops or not. If not, i am going to show a message box
including the error message.

Programmatically adding com refernce is possible?or not? Thanks...

Nov 17 '05 #6
Dear Sir,
there is no difference for end user what is added to your project as
reference.
Important is, how the referenced types are resolved at run time. So if user
has no word, then the first fuction, which uses classes from this interop
will throw an exception.
Just catch this exception or don't call this function, if word is not there.
Hope it makes sence. You might want to read in MSDN how types are resolved
(keyword reflection,
AssemblyResolve, ResolveEventHandler ...).

Best regards,
Boni

"Adam Right" <ad**@right.com> schrieb im Newsbeitrag
news:eE**************@TK2MSFTNGP14.phx.gbl...
Hi,

I am developing a project which uses "Microsoft Word Interop". There may
be a case in which the end-user may not have Microsoft Office or Office
Interops. So i do not want to add a com reference into my project from the
Solution Explorer by right-click "Add reference". I do want to add com
reference when the user loads the page that is going to show a "Microsoft
Word" document. In this case, while the page is loading, i can check that
the user has the interops or not. If not, i am going to show a message box
including the error message.

Programmatically adding com refernce is possible?or not? Thanks...

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fred Chen | last post by:
Hi, I've created a custom component. I want one of the properties of my custom component to be the output file name which is found in project properties. I know that I can get this by writing...
4
by: Thomas Jespersen | last post by:
Hello I want to create a MSI file programmatically. Do you know of any third party .NET component which can help me with that? I'm going to use it like a self extracting zip. So it is not...
1
by: dotnetnewbie | last post by:
Hi all I am new to .NET and webservice so I wish someone can shed some light on me. I have a Project class and a Product class, the Project can contain multiple Products (as an ArrayList). In...
2
by: Mark Broadbent | last post by:
Please guys save me from throwing my laptop throught the window grrr. No one answered my original post so here is a reworded version. I am working through some study material but have hit a brick...
0
by: Adam Right | last post by:
Hi, I am developing a project which uses "Microsoft Word Interop". There may be a case in which the end-user may not have Microsoft Office or Office Interops. So i do not want to add a com...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
11
by: Just Me | last post by:
I have a solution containing many usercontrol projects. When I wish to reference a usercontrol in another project I can select either the project or the assembly. Does it make a difference which...
0
by: Amongin Ewinyu | last post by:
Hi, Is it possible to programmatically install a windows component e.g.IIS? Is it possible to use a deployment project to install a Windows component? If so how would this be done? Again,...
3
by: Mike Lewis | last post by:
I need to add a reference to a custom component in a web service. I created a new web service using VS2005 but there was no place to add a reference in the Solution Explorer. I could use Notepad...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.