我做了一个Excel 2010 x64的插件,是一个自定义公式,结果在Excel中点击【Automation】添加时总是提示:
xxx.dll is not a valid Add-In
代码如下:
使用的WIX脚本生成MSI安装文件注册的:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace UDFDemo
{
[ComVisible(true), GuidAttribute("E8E9F986-97AA-4c22-A3A3-8C67991BD152")]
[ProgId("UDFDemo.UDFDemo.1")]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class UDFDemo
{
public double fnDiv(double num, int times, double result)
{
if (times <= 0)
{
throw new Exception("times必须为正整数!");
}
for (int i = 0; i < times; i++)
{
result += num / times;
}
return result;
}
}
}
开发环境:
Windows Server 2008 R2 DataCenter
Office 2010 Professional Plus Beta x64
Visual Studio 2010 Beta2
我不太明白,什么样的Add-In是有效的?希望朋友们帮忙看看,先谢了。
PS:因为是64位的Excel,故只能制作64位的Add-In.
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="a1d9e4c2-74ea-4176-9c8a-deb3c3a3fde1" Name="UDFMSI" Language="1033" Version="1.0.0.0" Manufacturer="UDFMSI" UpgradeCode="e2b52d40-53e3-422b-a7c9-35377e47ddc5">
<Package InstallerVersion="300" Compressed="yes" Platform="x64" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLLOCATION" Name="UDFMSI">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent" Guid="8046caf4-6e90-4002-bc2f-9007e028f5f8" Win64="yes">
<File Id="ProductComponent" Source="UDFDemo.dll" KeyPath="yes" Checksum="yes"/>
<RegistryValue Root="HKCR"
Key="CLSID\{E8E9F986-97AA-4c22-A3A3-8C67991BD152}\InprocServer32" Value="C:\Windows\system32\UDFDemo.dll" Type="string" Action="write" />
<RegistryValue Root="HKCR"
Key="CLSID\{E8E9F986-97AA-4c22-A3A3-8C67991BD152}\ProgID" Value="UDFDemo.UDFDemo.1" Type="string" Action="write" />
<RegistryValue Root="HKCR"
Key="CLSID\{E8E9F986-97AA-4c22-A3A3-8C67991BD152}\Programmable" Type="string" Value="" />
<RegistryValue Root="HKCR"
Key="CLSID\{E8E9F986-97AA-4c22-A3A3-8C67991BD152}\VersionIndependentProgID" Value="UDFDemo.UDFDemo" Type="string" Action="write" />
<!--<RegistryValue Root="HKCR"
Key="CLSID\{E8E9F986-97AA-4c22-A3A3-8C67991BD152}\Programmable\InprocServer32"
Name="FriendlyName" Value="C:\Windows\system32\UDFDemo.dll" Type="string" Action="write" />-->
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="UDFMSI" Level="1">
<!-- TODO: Remove the comments around this ComponentRef element and the Component above in order to add resources to this installer. -->
<ComponentRef Id="ProductComponent" />
<!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->
<ComponentGroupRef Id="Product.Generated" />
</Feature>
</Product>
</Wix>
不应该引用using Microsoft.Win32。