Hello,
I’ve got a curious deployment problem with my Word 2003 AddIn (VSTO 2005 SE). I’m deploying with a MSI Installer.
The Word AddIn has got some references to some other Assemblies. One of that references Assembly has a dependency of a C++ Assembly.
I can install my AddIn and it works without a problem in Word 2003. But when my code makes a call to that reference assembly which needs the C++ Assembly the Addin crashes, because the C++ Assembly can’t be found. The C++ Assembly contains in the MSI Package and will be found in the specific program folder.
I think the problem is that the AddIn Assembly will be load in the Assembly Cache when Word is started. But the C++ Assembly stays in the Program Folder and can’t be found by the AddIn.
Furthermore I've got done the steps from Jie Wang (http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/0675039c-eb7c-4961-b2c3-36a6a05b2e75) I've tested to install the dependency Assemblies in the GAC but without luck.
What can I do that the C++ Assembly can be found by my AddIn? |
| Lars Keller Wednesday, October 07, 2009 9:47 AM |
Hello Lars,
Could you please let me know what kind of the C++ assembly you are referring to? Is it the native C++ assembly(accessed by PInvoke), or native COM component, or managed assembly?
If it is a managed C++ assembly, putting in GAC should work fine.
If it is a native C++ dll and we are trying to us PInvoke to call its function. We should pay attention to the dll path because by default it will search in Office application folder to see if the native dll is there. That may cause the problem.
So would you mind confirming which kind of dll you are using and the exact error message you got, as well as the codes you call the dll function.
Ji Zhou
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact EMAIL REMOVED
Please remember to mark the replies as answers if they help and unmark them if they provide no help. |
| Ji.Zhou Thursday, October 08, 2009 8:09 AM |
Hi Ji,
Thanks for your response!
it is a little bit difficult because the AddIn uses different kinds of DLLs. Two DLLS are unmanaged (C++) DLLS. I install all managed DLLs in the GAC and copy the two unmanaged in the Office Folder (C:\Program Files\Microsoft Office\OFFICE11 \) but the error still occures.
The AddIn crashes when I declare a variable which type is contained in the dependency c++ assembly.
The error message is
Exception caught
System.TypeInitializationException: The type initializer for XXXX.YYYYYY.CCCCC threw an exception. ---> System.IO.FileNotFoundException: the specified module could not be found. (Exception from HRESULT: 0x8007007E)
at XXXX.YYYYYY.CCCCC..cctor()
--- End of inner exception stack trace ---
at XXXX.YYYYYY.CCCCC..ctor(IWin32Window parent, String s)
at XXXX.YYYYYY.CCCCC (IWin32Window parent, String input, String& output, Int64& id)
What kind of information do you need also? |
| Lars Keller Thursday, October 08, 2009 10:22 AM |
Hi Lars Are you loading the assemblies on demand with Load/Loadfrom. I remember that there was an issue in loading an assembly that wanted to have higher level priveledges and we changed our code to use the current assembly evidence policy and added this to the load assembly command. e.g
System.Security.Policy.
Evidence ev = System.Reflection.Assembly.GetExecutingAssembly().Evidence;
m = System.Reflection.
Assembly.LoadFrom("YOURASSEMBLY", ev);
This may assist you. Regards
Mike Walker MVP - Visual Developer VSTO - Please mark the best replies as Answers ! |
| Mike Walker Thursday, October 08, 2009 12:08 PM |
Hi Mike,
thanks for the hint! No I'm not loading the assemblies on demand. This thought is my next try if I can't get it work actually. |
| Lars Keller Thursday, October 08, 2009 12:20 PM |
Hello Lars,
Here are my two further suggestions,
1. Since the exception is FileNotFoundException, the tool Process Monitor can be a life saver in this situation. We can use it to log all file actions Office Word does. Typically, we can find a log entry that says Word is trying to find ***.dll file in *** folder, but it is not found. Based on those information, we can know where the unmanaged c++ dll is expected to be. This should give the right direction to solve this kind of issues. You can download the Process Monitor here, http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
2. If the issue cannot be resolved, would you mind sending me a copy of msi and I will investigate the issue locally. :-) You can access me via email "colbertz at microsoft dot com"
Ji Zhou
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact EMAIL REMOVED
Please remember to mark the replies as answers if they help and unmark them if they provide no help. - Marked As Answer byJi.ZhouMSFT, ModeratorTuesday, October 13, 2009 7:22 AM
- Unmarked As Answer byCindy MeisterMVP, ModeratorFriday, October 16, 2009 6:47 AM
-
|
| Ji.Zhou Friday, October 09, 2009 2:18 AM |
Any future support needed on this thread?
Please remember to mark the replies as answers if they help and unmark them if they provide no help. |
| Ji.Zhou Tuesday, October 13, 2009 7:22 AM |
Hi Ji,
thanks for your support! Actually I'm on vacation, but tomorrow I'm back at the office and will get a closer look with the process monitor. I'll give you feedback!
Cheers -Lars |
| Lars Keller Wednesday, October 14, 2009 11:23 AM |
Hi Ji,
a short update. I'm a little bit confused about my result and tomorrow I will check this again. All DLLs will be found by the addin but the error is the same. I think I've overridden something.
I'm not very adepted with C++. If there something I have to setting up with the unmanaged C++ Assembly to run it from Word?
Cheers -Lars |
| Lars Keller Thursday, October 15, 2009 7:36 PM |
Hi Ji,
so I've found all DLLs that are not correctly installed. For testing I've copied all unmanaged DLLs into the Office Program Folder. Now I get a new error....
System.BadImageFormatException: Invalid access to memory location. (Exception from HRESULT: 0x800703E6)
...but this is a good news ;-) I'll look at this error now.
What is the best strategy to install unmanaged DLL for an Office Addin? Install it to the Program Folder?
Cheers -Lars |
| Lars Keller Friday, October 16, 2009 1:36 PM |
If we are using PInvoke to consume these C++ dlls. I think putting it in the Office Folder should be enough. The System.BadImageFormatException looks very werid to me in this scenario. Is the C++ dll in 64 bit?
Would you mind sending me a copy of msi so that I can find a virtual box to reproduce and debug the issue locally. You can access me at colbertz at microsoft.com
Best regards, Ji Zhou
Please remember to mark the replies as answers if they help and unmark them if they provide no help. |
| Ji.Zhou 21 hours 35 minutes ago |