use*_*136 2 .net c# primary-interop-assembly ms-office .net-assembly
我正在尝试使用Microsoft Office Interops版本11,.NET 2.0修复使用Visual Studio 2003创建的此遗留应用程序.我正在尝试在Visual Studio Express 2010中修复它以引用Interops版本14,.NET 4.0 - 正如我之前关于StackOverflow的问题中所述,遗留应用程序在Windows 7中工作正常,但在我关闭它之后,Microsoft Office产品是当我尝试使用它们时崩溃.
但是,当我修复VS2010中的引用(删除旧的v.11 Interops,添加新的v.14 Interops)然后尝试发布应用程序时,我得到的错误就像
'Microsoft.Office.Interop.Word.System does not contain a definition for IO'
Run Code Online (Sandbox Code Playgroud)
看起来VS2010在引用Word命名空间时没有看到我的System命名空间被使用?当我删除了
using Microsoft.Office.Interop.Word
Run Code Online (Sandbox Code Playgroud)
命名空间然后尝试发布,上面的错误消失了,我只得到与缺少的Word引用相关的预期错误
The type or namespace name '_Document' could not be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我已经在参考中包含了System.dll,所以我不确定发生了什么?谢谢阅读!
编辑:我使Office Interops的"嵌入式互操作类型"为假.那可能修复了一些错误?但是:Visual Studio仍然将任何系统引用解释为"Microsoft.Office.Interop.Word.System",这不是我想要的.这个错误似乎是现在的主导:
The type name 'Windows' does not exist in the type 'Microsoft.Office.Interop.Word.System'
Run Code Online (Sandbox Code Playgroud)
小智 5
这个问题发生在我身上,只有当我把使用的东西放在命名空间定义之后,如下所示:
namespace Addin
{
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
..........................
Run Code Online (Sandbox Code Playgroud)
正确的方法是:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Addin
{
....................
Run Code Online (Sandbox Code Playgroud)
可以帮到你!