.Net Office AddIn Failure

D

Daniel Chalef

Hi,

I am having some difficulty getting my Office Add-In
(which integrates Office
with our Document Management System) running on a machine
that doesn't have
Visual Studio .NET on it also.

The CommandBars that the AddIn creates don't appear, and
AddIn never gets
instantiated (I have some logging code in the constructor
of the class that
implements IDTExtensibility2 that doesn't get executed-
since the log file
never appears).

The AddIn requires the .NET Framework 1.1 and Web Service
Enhancements 1.0
to enable it to talk SOAP and DIME to the DMS.
I've tried
with:
- Office XP, SP1 and SP2 all exhibit the same symptoms-
the AddIn fails to
load, isn't listed under COM Add-Ins, despite showing up
in System
Information.
- Office 2003 shows the AddIn under COM Add-Ins with the
error message: "Not
loaded. A runtime error occurred during the loading of
the COM Add-in"

Any diagnostics, clues, ideas will be greatly appreciated.

Thanks
Daniel
 
W

Wei-Dong Xu [MSFT]

Hi Daniel,

Thank you for posting in MSDN managed newsgroup!

By default, the .Net add-in will not be displayed in the com add-in manager window because com add-in manager will treat the .net add-in as the
same as to com. If you want to display the .net add-in in the add-in manager, you will need to strong named the assembly and register it in the GAC
and then register the assembly with COM interop. There is one setup project in the shared add-in solution which may help you to finish these steps.
The KB article 316723 and 302901 will provide more information for you. Please go to
316723 PRB: Visual Studio .NET Shared Add-in Is Not Displayed in Office COM
http://support.microsoft.com/?id=316723

302901 HOW TO: Build an Office COM Add-in by Using Visual C# .NET
http://support.microsoft.com/?id=302901

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Daniel Chalef

Hi Wei-Dong,

I have done the following:
- generated a strong name keypair using sn.exe:
sn -k KnowledgeTreeAddIn.snk
- added a reference to it in AssemblyInfo.cs:
[assembly: AssemblyKeyFile(@"..\..\KnowledgeTreeAddIn.snk")]
- Added the GAC Folder to my setup project and added the
project primary output to this folder

I now get tbe following error when I rebuild:

Assembly 'Primary output from KnowledgeTreeAddIn (Active)'
cannot be in the Global Assembly Cache because its
dependency 'Interop.Word' (Version='9.0.0.0') is not
strongly named.

and the same for the other Office assemblies that I'm using.

Can I strong name these assemblies? Is there a workaround?

thanks
Daniel
-----Original Message-----
Hi Daniel,

Thank you for posting in MSDN managed newsgroup!

By default, the .Net add-in will not be displayed in the
com add-in manager window because com add-in manager will
treat the .net add-in as the
same as to com. If you want to display the .net add-in in
the add-in manager, you will need to strong named the
assembly and register it in the GAC
and then register the assembly with COM interop. There is
one setup project in the shared add-in solution which may
help you to finish these steps.
The KB article 316723 and 302901 will provide more
information for you. Please go to
 
D

Daniel Chalef

com add-in manager window because com add-in manager will
treat the .net add-in as the

Its not that the add-in is not being displayed in the
add-in manager, its that its not being loaded- even if the
security level (Tools->Macro->Security) is set to low and
"Trust all installed add-ins and templates" is checked.

From what I've been reading, using the COM Add-in Shim
Solution allows you to install a .NET add-in in Office XP
with security level set to high.

The following posts now make me think that I'm missing the
PIAs on the target machines:
http://tinyurl.com/x76m
http://tinyurl.com/x76t
 
S

Siew Moi Khor [MS]

Hi Daniel,
I also think indeed you're missing the PIAs on the target machines. You can
find guidelines on using Office XP PIAs here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/odc_oxppias.asp

Also check out the known issues. if you scroll all the way down, you'll
find guidelines what to package and what not to:
http://msdn.microsoft.com/library/en-us/dnoxpta/html/odc_piaissues.asp

For Office 2003 PIAs usage guidelines and how to get them, for now, you can
find info in the docs included in the download on gotdotnet. You can ignore
the smart tags sample which would be irrelevant here but to get to the docs,
you'll have to download the whole thing..
http://www.gotdotnet.com/Community/...mpleGuid=36dd342d-d732-408c-b96b-8db865cb53c7

Siew Moi
 
D

Daniel Chalef

The story so far:
- I've downloaded and installed the PIAs on the target
machines and verified that they are now registered in the
GAC with gacutil.
- Used tlbimp to generate strongly named assemblies from
the interop type libs:
tlbimp "C:\Program Files\Microsoft
Office\OFFICE11\MSPPT.OLB" /out:powerPoint.dll
/keyfile:powerpoint.snk
(same for MSWORD.OLB, EXCEL.EXE)
- Strong named my assembly in AssemblyInfo.cs with:
[assembly: AssemblyKeyFile(@"..\..\KnowledgeTreeAddIn.snk")]
- Registered the primary output from my project in the GAC
using the FileSystem section of the Setup project.
- Excluded the PIAs from my setup project (as they're now
already on the target machine?)

I can now verify that my dll is in the GAC after I run the
addin setup msi, but the behaivour is the same:
- Office 2003: The addin shows up in the COM AddIns dialog
with the Location: set to blocks (from a character set not
installed?) and Load Behavior: Not loaded. A runtime error
occurred during the loading of the COM Add-in. The
LoadBehaviour registry key also gets changed from a 3 to a 2.
- Office XP: Nothing in the COM AddIns dialog, but the
LoadBehaviour registry key gets changed- which I take to
mean something caused the addin to bomb on startup.

Also, System Information (Help->About->System Info)
verifies that the addin is registered: Office 2003
Applications -> Microsoft Office Word -> COM Add-Ins

Is there any way to find out what caused the add-in not to
load? No Office logging configuration setting?

thanks for the help so far :)
-----Original Message-----
For Office 2003 PIAs usage guidelines and how to get them, for now, you can
find info in the docs included in the download on gotdotnet. You can ignore
the smart tags sample which would be irrelevant here but to get to the docs,
you'll have to download the whole thing..
http://www.gotdotnet.com/Community/...mpleGuid=36dd342d-d732-408c-b96b-8db865cb53c7

are you talking about Managed Smart Tags Security
Policy.doc or ReadMe_VBNetSmartTagEg.txt?
 
W

Wei-Dong Xu [MSFT]

Hi Daniel,

Thank you for replying and the detailed information about the troubleshooting!

It is unnecessary for you to strong name the office *.olb files. You can directly reference the office PIA component in your project. After the
installation of PIA (office XP PIA or office 2003 PIA), in your project of visual studio, please select "Project->Add Reference...". In the com tab,
select "Microsoft Excel 10.0 object library"(office xp PIA installed ) or "Microsoft Excel 11.0 object library"(office 2003 PIA installed) and other
component used in your project. In this way, your project will reference to the PIA component automatically. You will only need strong name the
add-in you are developing. Then in the deployment box, you should install the related PIA first before installation. This is to say, you should install
office XP PIA first if you reference the Office 10.0 object library in the project, vice versa, office 2003 PIA.

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Daniel Chalef

Ok, I am now just trying to deploy a dummy addin with no
success. I do the following:
- Create a new Shared Add-in Extensibility project with
VS .NET 2003
- I check "load my addin when the host application
loads" and leave "My addin should be available to all
users blah blah blah" unchecked as per the advice from
this post: http://tinyurl.com/xdcc
- I then strong name my assembly and add it to the GAC in
the setup deployment project.

So, no PIAs, nothing fancy in the
Extensibility.IDTExtensibility2 implementation, just some
MessageBox.Show()s.

When the assembly is added to the GAC the addin fails.
When the project output is just in the Application Folder
in the setup project then the addin loads and I see the
MessageBoxes.

I am now seeing some better results if I then attempt to
integrate the new addin project with my existing
application code.

Will post more details tomorrow.

Thanks for all the help so far.
 
D

Daniel Chalef

So, now it works :)
Even on machines that don't have the PIAs installed!
Last night I created a new Shared Add-in Extensibility
project and replaced the Connect class in my current
solution. I have verified that it now executes on both
Office 2003 and OfficeXP with the PIAs installed. And
without?!
My addin assembly is not strong named, nor is it installed
into the GAC in the setup project.
Could it be that my Add-in project was corrupted somehow?
Very puzzling, but thankfully resolved now :)

thanks for the help.

I have some another questions regarding CommandBarButton
event handlers, but I will post this separately.
 
W

Wei-Dong Xu [MSFT]

Hi Daniel,

Thank you for replying and more information regarding this issue!

You are very welcome!

Thank you once more for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kevin Yu

Wei-Don

I have a question for you. I did a office 2000 COM addin with vs.net, it all works find, but now it doesn't work in office 2003, since I was using office XP PIA, now I try to rewrite the addin for office 2003, I can get the addin to load properly but the commandbarbutton working, but with the the Microsoft.Office.Interop.word and such, I can't access the text and other properties of the document, since I can't declare object like Microsoft.Office.Interope.word. I can't find any similar stuff on office 2003. all I can find is the VSTO, how can I make it work in my COM addin? thx
 
W

Wei-Dong Xu [MSFT]

Hi,

I'd suggest you can check the version of reference office com component. In
one box installed office 2003, you can find the office 11.0 library and
other library(word, excel etc) from Project->Add Reference->Com in visual
studio.net. Then import the namespace into your source code, for example
[C#]
using Microsoft.Office.Core;
using oWord = Microsoft.Office.Interop.Word;
[Visaul Basic.Net]
Imports Microsoft.Office.Core
Imports oWord = Microsoft.Office.Interop.Word

The "oWord" is one alias for the long namespace, this will be simple for us
to write code without typing too much namespace everywhere. You can feel
free to use any name (don't use some name which will cause name conflict,
for example System etc )

After referencing the related object library, you can click "Ctrl+Alt+J" to
open the object viewer to see the object methods, interfaces etc which will
be very helpful for your development.

If you are going to declare one Word.Application object in the project, you
can write the codes as below:
[C#]
oWord.ApplicationClass oWdAPP = new oWord.ApplicationClass();
oWdAPP.Visible = true;
[Visual Basic.Net]
Dim oWdAPP As oWord.ApplicationClass
oWdAPP = New oWord.ApplicationClass

In addition, I'd suggest you can post one new issue in the newsgroup so
that other community members can also provide some assistance and it will
be easy for us to track your issue.

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kevin

yes,I found that out last night, so the problem is fixed now, my new question is if I want to the addin to work for all version of office, I need to compile the COM addin with different version of the COM objects? whatelse can I do to make it work on all version of office? thx

----- Wei-Dong Xu [MSFT] wrote: -----

Hi,

I'd suggest you can check the version of reference office com component. In
one box installed office 2003, you can find the office 11.0 library and
other library(word, excel etc) from Project->Add Reference->Com in visual
studio.net. Then import the namespace into your source code, for example
[C#]
using Microsoft.Office.Core;
using oWord = Microsoft.Office.Interop.Word;
[Visaul Basic.Net]
Imports Microsoft.Office.Core
Imports oWord = Microsoft.Office.Interop.Word

The "oWord" is one alias for the long namespace, this will be simple for us
to write code without typing too much namespace everywhere. You can feel
free to use any name (don't use some name which will cause name conflict,
for example System etc )

After referencing the related object library, you can click "Ctrl+Alt+J" to
open the object viewer to see the object methods, interfaces etc which will
be very helpful for your development.

If you are going to declare one Word.Application object in the project, you
can write the codes as below:
[C#]
oWord.ApplicationClass oWdAPP = new oWord.ApplicationClass();
oWdAPP.Visible = true;
[Visual Basic.Net]
Dim oWdAPP As oWord.ApplicationClass
oWdAPP = New oWord.ApplicationClass

In addition, I'd suggest you can post one new issue in the newsgroup so
that other community members can also provide some assistance and it will
be easy for us to track your issue.

Please feel free to let me know if you have any further questions.

Does this answer your question? Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Wei-Dong Xu [MSFT]

Hi,

Thank you for replying!

That's a good news you have solved the question. If you want to make the
add-in to work in all versions of Office, you may need to follow the method
introduced by the kb article 316723.
316723 PRB: Visual Studio .NET Shared Add-in Is Not Displayed in Office COM
http://support.microsoft.com/?id=316723

However, since this kb applies to some products of office 2002, you will
need to test you solution for each version of office. Furthermore, the kb
article 302901 will provide some assistance for you regarding this issue:
302901 HOW TO: Build an Office COM Add-in by Using Visual C# .NET
http://support.microsoft.com/?id=302901

Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top