Skip to content

Commit b9fba7b

Browse files
committed
Create Master/Slave sample (and test)
1 parent 8f85c2e commit b9fba7b

15 files changed

+529
-2
lines changed

Diff for: MasterSlave/Master/Master-AddIn.dna

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<DnaLibrary Name="Master Add-In" RuntimeVersion="v4.0">
2+
<ExternalLibrary Path="Master.dll" LoadFromBytes="true" Pack="true" />
3+
4+
<!--
5+
The RuntimeVersion attribute above allows two settings:
6+
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5
7+
* RuntimeVersion="v4.0" - for .NET 4 and 4.5
8+
9+
Additional referenced assemblies can be specified by adding 'Reference' tags.
10+
These libraries will not be examined and registered with Excel as add-in libraries,
11+
but will be packed into the -packed.xll file and loaded at runtime as needed.
12+
For example:
13+
14+
<Reference Path="Another.Library.dll" Pack="true" />
15+
16+
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file.
17+
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution.
18+
-->
19+
20+
</DnaLibrary>

Diff for: MasterSlave/Master/Master.csproj

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>MasterSlave</RootNamespace>
11+
<AssemblyName>Master</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="ExcelDna.Integration, Version=0.33.5730.40390, Culture=neutral, processorArchitecture=MSIL">
34+
<HintPath>..\packages\ExcelDna.Integration.0.33.9\lib\ExcelDna.Integration.dll</HintPath>
35+
<Private>False</Private>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="Ribbon.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Content Include="Master-AddIn.dna">
52+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
53+
</Content>
54+
<None Include="packages.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<PropertyGroup>
58+
<PostBuildEvent>xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "$(TargetDir)Master-AddIn.xll*" /C /Y
59+
xcopy "$(TargetDir)Master-AddIn.dna*" "$(TargetDir)Master-AddIn64.dna*" /C /Y
60+
xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna64.xll" "$(TargetDir)Master-AddIn64.xll*" /C /Y
61+
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)Master-AddIn.dna" /Y
62+
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)Master-AddIn64.dna" /Y</PostBuildEvent>
63+
</PropertyGroup>
64+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
65+
Other similar extension points exist, see Microsoft.Common.targets.
66+
<Target Name="BeforeBuild">
67+
</Target>
68+
<Target Name="AfterBuild">
69+
</Target>
70+
-->
71+
</Project>

Diff for: MasterSlave/Master/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Master")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Master")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("255ea622-10f7-4a1f-8cc4-053dec4e0aa0")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Diff for: MasterSlave/Master/Ribbon.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using ExcelDna.Integration;
9+
using ExcelDna.Integration.CustomUI;
10+
11+
namespace MasterSlave
12+
{
13+
[ComVisible(true)]
14+
public class Ribbon : ExcelRibbon
15+
{
16+
public Ribbon()
17+
{
18+
}
19+
20+
public override string GetCustomUI(string RibbonID)
21+
{
22+
XlCall.Excel(XlCall.xlcMessage, "BANG!!!!");
23+
Console.Beep();
24+
Console.Beep();
25+
Console.Beep();
26+
return
27+
@"
28+
<customUI xmlns = 'http://schemas.microsoft.com/office/2006/01/customui' >
29+
<ribbon>
30+
<tabs>
31+
<tab id = 'CustomTab' label = 'My Tab' >
32+
<group id = 'SampleGroup' label = 'My Sample Group' >
33+
<button id = 'Button1' label = 'My Button Label' size = 'large' onAction = 'RunTagMacro' tag = 'ShowHelloMessage' />
34+
<button id = 'Button2' label = 'My Second Button' size = 'normal' onAction = 'OnButtonPressed' />
35+
</group>
36+
</tab>
37+
</tabs>
38+
</ribbon>
39+
</customUI>
40+
";
41+
}
42+
}
43+
44+
}

Diff for: MasterSlave/MasterSlave.sln

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Master", "Master\Master.csproj", "{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Slave", "Slave\Slave.csproj", "{9245231C-6B34-40B4-A1EA-29A987B042FA}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestController", "TestController\TestController.csproj", "{A7D2C0D4-DC96-4A3B-92EA-0A9BA1DFF681}"
11+
ProjectSection(ProjectDependencies) = postProject
12+
{9245231C-6B34-40B4-A1EA-29A987B042FA} = {9245231C-6B34-40B4-A1EA-29A987B042FA}
13+
{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0} = {255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}
14+
EndProjectSection
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CD534D4E-2D58-4998-B569-604D8FCC0F9A}"
17+
ProjectSection(SolutionItems) = preProject
18+
Readme.md = Readme.md
19+
EndProjectSection
20+
EndProject
21+
Global
22+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
23+
Debug|Any CPU = Debug|Any CPU
24+
Release|Any CPU = Release|Any CPU
25+
EndGlobalSection
26+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
27+
{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{255EA622-10F7-4A1F-8CC4-053DEC4E0AA0}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{9245231C-6B34-40B4-A1EA-29A987B042FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{9245231C-6B34-40B4-A1EA-29A987B042FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{9245231C-6B34-40B4-A1EA-29A987B042FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{9245231C-6B34-40B4-A1EA-29A987B042FA}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{A7D2C0D4-DC96-4A3B-92EA-0A9BA1DFF681}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{A7D2C0D4-DC96-4A3B-92EA-0A9BA1DFF681}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{A7D2C0D4-DC96-4A3B-92EA-0A9BA1DFF681}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{A7D2C0D4-DC96-4A3B-92EA-0A9BA1DFF681}.Release|Any CPU.Build.0 = Release|Any CPU
39+
EndGlobalSection
40+
GlobalSection(SolutionProperties) = preSolution
41+
HideSolutionNode = FALSE
42+
EndGlobalSection
43+
EndGlobal

Diff for: MasterSlave/Readme.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The MasterSlave sample shows how an add-in host can control loading and unloading of other add-ins.
2+
3+
The Master add-in displays a ribbon with two buttons, to load and unload the Slave add-in.
4+
5+
In addition, there is TestController application (a console application) which loads and controls the Master add-in, and attempts to detect whether the Excel process exits with an error. This is to test for a reported error on closing Excel when an add-in has been unregistered.
6+

Diff for: MasterSlave/Slave/AddIn.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Slave
8+
{
9+
public class Class1
10+
{
11+
}
12+
}

Diff for: MasterSlave/Slave/Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Slave")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Slave")]
13+
[assembly: AssemblyCopyright("Copyright © 2016")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("9245231c-6b34-40b4-a1ea-29a987b042fa")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Diff for: MasterSlave/Slave/Slave-AddIn.dna

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<DnaLibrary Name="Slave Add-In" RuntimeVersion="v4.0">
2+
<ExternalLibrary Path="Slave.dll" LoadFromBytes="true" Pack="true" />
3+
4+
<!--
5+
The RuntimeVersion attribute above allows two settings:
6+
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5
7+
* RuntimeVersion="v4.0" - for .NET 4 and 4.5
8+
9+
Additional referenced assemblies can be specified by adding 'Reference' tags.
10+
These libraries will not be examined and registered with Excel as add-in libraries,
11+
but will be packed into the -packed.xll file and loaded at runtime as needed.
12+
For example:
13+
14+
<Reference Path="Another.Library.dll" Pack="true" />
15+
16+
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file.
17+
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution.
18+
-->
19+
20+
</DnaLibrary>

Diff for: MasterSlave/Slave/Slave.csproj

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9245231C-6B34-40B4-A1EA-29A987B042FA}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>MasterSlave</RootNamespace>
11+
<AssemblyName>Slave</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\Debug\</OutputPath>
20+
<DefineConstants>DEBUG;TRACE</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<Reference Include="ExcelDna.Integration, Version=0.33.5730.40390, Culture=neutral, processorArchitecture=MSIL">
34+
<HintPath>..\packages\ExcelDna.Integration.0.33.9\lib\ExcelDna.Integration.dll</HintPath>
35+
<Private>False</Private>
36+
</Reference>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Xml.Linq" />
40+
<Reference Include="System.Data.DataSetExtensions" />
41+
<Reference Include="Microsoft.CSharp" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Xml" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<Compile Include="AddIn.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Content Include="Slave-AddIn.dna">
52+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
53+
</Content>
54+
<None Include="packages.config" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57+
<PropertyGroup>
58+
<PostBuildEvent>xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna.xll" "$(TargetDir)Slave-AddIn.xll*" /C /Y
59+
xcopy "$(TargetDir)Slave-AddIn.dna*" "$(TargetDir)Slave-AddIn64.dna*" /C /Y
60+
xcopy "$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDna64.xll" "$(TargetDir)Slave-AddIn64.xll*" /C /Y
61+
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)Slave-AddIn.dna" /Y
62+
"$(SolutionDir)\packages\ExcelDna.AddIn.0.33.9\tools\ExcelDnaPack.exe" "$(TargetDir)Slave-AddIn64.dna" /Y</PostBuildEvent>
63+
</PropertyGroup>
64+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
65+
Other similar extension points exist, see Microsoft.Common.targets.
66+
<Target Name="BeforeBuild">
67+
</Target>
68+
<Target Name="AfterBuild">
69+
</Target>
70+
-->
71+
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="ExcelDna.AddIn" version="0.33.9.65" targetFramework="net4" />
4-
<package id="ExcelDna.Integration" version="0.33.9" targetFramework="net4" />
3+
<package id="ExcelDna.AddIn" version="0.33.9" targetFramework="net45" />
4+
<package id="ExcelDna.Integration" version="0.33.9" targetFramework="net45" />
55
</packages>

0 commit comments

Comments
 (0)