Oleg Krupnov

Hi,

I've built a VSTO 2005 solution for Word that works perfectly in Word 2003, but fails in Word 2007. It's hard to fix the error without debugging, so my question is: Is there a way to debug a VSTO 2005 solution with running Word 2007 If not, what would you suggest me

Thanks.


Re: Visual Studio Tools for Office How to Debug a VSTO 2005 Solution with Office 2007?

Geoff Darst - MSFT

Hi Oleg,

Let me try to read between the lines here. Since you are developing a customization that you expect to run on Word 2007, I'm assuming you have written an Add-In Presumably you are asking how to debug an Add-In that has been deployed to a machine that does not have Visual Studio on it. Have I got it right I hope so, since VSTO 2005 document customizations aren't expected to run on Word 2007 (you'll need to upgrade to VSTO 3.0 when it ships).

If so, as long as the machines are networked, you can set up a remote debugging session. To start with, you will want to copy Install path\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86\msvsmon.exe up to a share (Install path is %ProgramFiles% if Visual Studio was installed in the default location). Then go to your target machine, connect to the share and run msvsmon. You will need to open up your firewall to enable remote debugging; msvsmon will prompt you to do this when you start it up. If you are logged on to the target machine with a different user account than the one you are debugging from, you will need to select Permissions on msvsmon and add your user account so you can debug.

Next go to the machine where you have Visual Studio installed and load up your project. Right click the project icon in Solution Explorer and choose "Properties". Select the "Debug" tab. For "Start Action", select "Start external program" and enter fully qualified path to winword.exe as it exists on the remote machine. Click the "Use remote machine" check box and enter the path to the debugging server exactly as it appears in the msvsmon window. Typically, it will be something like <domain>\<user>@<machine name>.

At this point, you can hit F5 and Word should launch on the remote machine with the debugger attached. However, you have to sort out the symbol issue. If you happened to have deployed symbols to the remote machine, then debugging will just work. Otherwise, you'll need to set your symbol path to point to a location where matching symbols reside. To do this go to the "Tools" menu in Visual Studio, choose "Debugging", click "Symbols" and specify a path. Once your symbols are sorted out, you can set breakpoints normally. Assuming your add-in is loading when Word starts up, you will hit your break points as expected. If you don't hit your break points, go to the modules window and verify that A) your Add-in really did load and B) symbols were loaded along with it.

Sincerely,

Geoff Darst

Microsoft VSTO Team





Re: Visual Studio Tools for Office How to Debug a VSTO 2005 Solution with Office 2007?

Oleg Krupnov

Thanks Geoff.

Your assumption was not correct. I am developing a Word document template customization, not an application-level add-in. I expect it to run on Word because I include the Office 2007 PIAs to my deployment package. And it does run in Word 2007, but there are bugs I'd like to track.

Are the instructions going to be different for the document template customization compared to the add-in you have given above

Also, I'm running Office 2007 on a Virtual PC on the same computer, not on the local network. Is there a way to debug in VirtualPC or maybe via Internet I don't have any LAN.

Thanks




Re: Visual Studio Tools for Office How to Debug a VSTO 2005 Solution with Office 2007?

Geoff Darst - MSFT

Hi Oleg,

I see what you are doing. The debugging instructions will still be basically the same--though you might want to add the document to the command line to make your F5 experience more seamless. As far as setting up remote debugging on a Virtual PC, you'll probably want to have a look at the following whitepaper: http://www.microsoft.com/windows/products/winfamily/virtualpc/debug.mspx. It will walk you through getting remote debugging setup on a Virtual PC.

Sincerely,

Geoff Darst

Microsoft VSTO Team





Re: Visual Studio Tools for Office How to Debug a VSTO 2005 Solution with Office 2007?

Oleg Krupnov

Hi Geoff,

Thank you for the valuable links!

Unfortunately, I'm still facing a VSTO-specific security issue.

1) I'm deploying my customization assembly to the virtual PC using a setup package. The package also runs the SetSecurity and UpdateManifest custom actions that usually resolves all security problems on the local machine (but not on the virtual machine as you will see below)

2) For debugging purpose, deployed is the assembly built in the *DEBUG* configuration. I also copied manually the *.pdb file to the location where the assembly *.dll file is deployed.

3) When I hit F5 as you described above, I receive the following security error message on the virtual machine (see below Error #1)

4) I have also tried to first run the customization on the target machine (that works) and then attach to it using VS Debug->Attach to Process->WINWORD.EXE. I receive the following error message on the debugger machine (see below Error #2), and then no breakpoints work.

Please advise!

-------------------------------------------------------

Error #1

Could not load file or assembly MyAssembly, Version=2.0.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

************** Exception Text **************

System.IO.FileLoadException: Could not load file or assembly MyAssembly, Version=2.0.1.0, Culture=neutral, PublicKeyToken= xxxxxxxxxxxxxxxx ' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

File name: MyAssembly, Version=2.0.1.0, Culture=neutral, PublicKeyToken= xxxxxxxxxxxxxxxx ' ---> System.Security.Policy.PolicyException: Execution permission cannot be acquired.

at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission)

at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission)

at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.HandleOnlineOffline(Exception e, String basePath, String filePath)

at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadStartupAssembly(EntryPoint entryPoint, Dependency dependency, Dictionary`2 assembliesHash)

at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.ConfigureAppDomain()

at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadAssembliesAndConfigureAppDomain(IHostServiceProvider serviceProvider)

at Microsoft.VisualStudio.Tools.Applications.Runtime.AppDomainManagerInternal.LoadEntryPointsHelper(IHostServiceProvider serviceProvider)

-------------------------------------------------------

Error #2

The following module was built either with optimization enabled or without debug information:

(<path on virtual machine>)C:\Document and Settings\User1\Local Settings\Application Data\...\MyAssembly.DLL

To debug this module, change its project build configuration to Debug mode. To suppress this message, disable the "Warn if no user code on launch" debugger option.