Skip to content

Commit cb7a692

Browse files
committed
Registration.Sample: Clean up project a bit
1 parent c165f30 commit cb7a692

15 files changed

+114
-148
lines changed

CustomTaskPane/CustomTaskPane.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ExcelDna.Addin" Version="*-*" />
9+
<PackageReference Include="ExcelDna.Addin" Version="1.7.0-rc9" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

CustomTaskPane/Ribbon.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System.Diagnostics;
2+
using System.Runtime.InteropServices;
23
using ExcelDna.Integration.CustomUI;
34

45
namespace CustomTaskPane
@@ -8,6 +9,7 @@ public class MyRibbon : ExcelRibbon
89
{
910
public override string GetCustomUI(string RibbonID)
1011
{
12+
Debug.Print("CustomTaskPane.GetCustomUI");
1113
return
1214
@"<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui' loadImage='LoadImage'>
1315
<ribbon>

DnaComServer/AddIn.cs

+17-7
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22
using ExcelDna.ComInterop;
33
using ExcelDna.Integration;
44

5+
[assembly:ComVisible(false)]
6+
57
namespace DnaComServer
68
{
9+
10+
[ComVisible(true)]
711
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
8-
public interface IComLibrary
12+
public interface IComLibraryC
913
{
1014
string ComLibraryHello();
1115
double Add(double x, double y);
1216
}
1317

14-
[ComDefaultInterface(typeof(IComLibrary))]
15-
public class ComLibrary
18+
[ComVisible(true)]
19+
[ComDefaultInterface(typeof(IComLibraryC))]
20+
public class ComLibraryC
1621
{
22+
public ComLibraryC()
23+
{
24+
}
25+
1726
public string ComLibraryHello()
1827
{
1928
return "Hello from DnaComServer.ComLibrary";
@@ -25,15 +34,17 @@ public double Add(double x, double y)
2534
}
2635
}
2736

37+
[ComVisible(true)]
2838
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
29-
public interface IComLibrary2
39+
public interface IComLibrary2C
3040
{
3141
string ComLibrary2Hello();
3242
double Add2(double x, double y);
3343
}
3444

35-
[ComDefaultInterface(typeof(IComLibrary2))]
36-
public class ComLibrary2
45+
[ComVisible(true)]
46+
[ComDefaultInterface(typeof(IComLibrary2C))]
47+
public class ComLibrary2C
3748
{
3849
public string ComLibrary2Hello()
3950
{
@@ -46,7 +57,6 @@ public double Add2(double x, double y)
4657
}
4758
}
4859

49-
[ComVisible(false)]
5060
public class ExcelAddin : IExcelAddIn
5161
{
5262
public void AutoOpen()

DnaComServer/DnaComServer.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
4+
<TargetFramework>net6.0-windows</TargetFramework>
55
<ExcelAddInComServer>true</ExcelAddInComServer>
6+
<Version>1.0.0.0</Version>
67
</PropertyGroup>
78

89
<ItemGroup>
9-
<PackageReference Include="ExcelDna.Addin" Version="*-*" />
10+
<PackageReference Include="ExcelDna.Addin" Version="1.7.0-rc7" />
1011
<PackageReference Include="dSPACE.Runtime.InteropServices.BuildTasks" Version="1.2.0"/>
1112
</ItemGroup>
1213

DnaComServer/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ namespace DnaComServer
142142

143143
```vb
144144
Sub TestEarlyBound()
145-
Dim dnaComServer As DnaComServer.ComLibrary
145+
Dim dnaComServer As DnaComServer.IComLibrary
146146
Dim hello As String
147147
Dim result As Double
148148

GenericHost/AddIn.cs

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
@@ -11,8 +12,34 @@ public class AddIn : IExcelAddIn
1112
{
1213
public void AutoOpen()
1314
{
14-
BuildConfiguration()
15-
.Register();
15+
var config = BuildConfiguration();
16+
Debug.Print("AutoOpen - Enter");
17+
Task.Run(async () =>
18+
{
19+
await Task.Delay(10000);
20+
Debug.Print("AutoOpen - Enqueue Configure");
21+
ExcelAsyncUtil.QueueAsMacro(() =>
22+
{
23+
config.Register();
24+
Debug.Print("AutoOpen - Register");
25+
});
26+
await Task.Delay(10000);
27+
Debug.Print("AutoOpen - Enqueue Configure 2");
28+
ExcelAsyncUtil.QueueAsMacro(() =>
29+
{
30+
config.Register();
31+
Debug.Print("AutoOpen - Register 2");
32+
});
33+
});
34+
//ExcelAsyncUtil.QueueAsMacro(() =>
35+
//{
36+
// Debug.Print("AutoOpen - QueueAsMacro");
37+
// BuildConfiguration()
38+
// .Register();
39+
// Debug.Print("AutoOpen - Register");
40+
//});
41+
Debug.Print("AutoOpen - Exit");
42+
1643
}
1744

1845
public void AutoClose()
@@ -23,9 +50,17 @@ static AddInConfiguration BuildConfiguration()
2350
{
2451
return new AddInConfiguration
2552
{
26-
FunctionRegistration = new MyCustomFunctionRegistration(),
53+
//FunctionRegistration = new MyCustomFunctionRegistration(),
2754
RibbonRegistration = new MyCustomRibbonRegistration()
2855
};
2956
}
57+
58+
59+
[ExcelCommand(ShortCut ="^R")]
60+
public static void RegisterRibbon()
61+
{
62+
var ribbon = new MyCustomRibbon();
63+
ExcelComAddInHelper.LoadComAddIn(ribbon);
64+
}
3065
}
3166
}

GenericHost/AddInConfiguration.cs

+2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public void Register()
2626
if (RibbonRegistration != null)
2727
{
2828
foreach (var addIn in RibbonRegistration.GetRibbonAddIns())
29+
{
2930
ExcelComAddInHelper.LoadComAddIn(addIn);
31+
}
3032
}
3133
}
3234
}

GenericHost/GenericHost.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<PropertyGroup>
44
<TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
55
<UseWindowsForms>true</UseWindowsForms>
6+
7+
<!--<ExcelAddInExplicitRegistration>true</ExcelAddInExplicitRegistration>
8+
<ExcelAddInExplicitExports>true</ExcelAddInExplicitExports>-->
69
</PropertyGroup>
710

811
<ItemGroup>

GenericHost/MyCustomRibbon.cs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ internal interface IRibbonExtensibility
2424
string GetCustomUI(string RibbonID);
2525
}
2626

27+
[ProgId("GenericHost.MyCustomRibbon")]
28+
[Guid("E595901B-903E-4FE7-8D06-6E7F3D5A2C4F")]
2729
[ComVisible(true)]
2830
[ClassInterface(ClassInterfaceType.AutoDispatch)]
2931
public class MyCustomRibbon : ExcelComAddIn, IRibbonExtensibility
+32-32
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
3-
using System.Runtime.InteropServices;
1+
//using System.Reflection;
2+
//using System.Runtime.CompilerServices;
3+
//using System.Runtime.InteropServices;
44

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("GenericHost")]
9-
[assembly: AssemblyDescription("")]
10-
//[assembly: AssemblyConfiguration("")]
11-
//[assembly: AssemblyCompany("")]
12-
//[assembly: AssemblyProduct("GenericHost")]
13-
[assembly: AssemblyCopyright("Copyright © 2020")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
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("GenericHost")]
9+
//[assembly: AssemblyDescription("")]
10+
////[assembly: AssemblyConfiguration("")]
11+
////[assembly: AssemblyCompany("")]
12+
////[assembly: AssemblyProduct("GenericHost")]
13+
//[assembly: AssemblyCopyright("Copyright © 2020")]
14+
//[assembly: AssemblyTrademark("")]
15+
//[assembly: AssemblyCulture("")]
1616

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)]
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)]
2121

22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("745b1392-20a9-4e19-b13c-4894b813c88c")]
22+
//// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
//[assembly: Guid("745b1392-20a9-4e19-b13c-4894b813c88c")]
2424

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")]
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")]

Registration.Sample/Properties/AssemblyInfo.cs

-12
This file was deleted.

Registration.Sample/Properties/ExcelDna.Build.props

-77
This file was deleted.

Registration.Sample/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Excel-DNA Custom Registration Example
2-
=====================================
1+
Excel-DNA Registration Example
2+
==============================
33

4-
This C# add-in shows how the ExcelDna.CustomRegistration helper library may be used.
4+
This C# add-in shows how the ExcelDna.Registration helper library may be used.
55

66
AddIn.cs
77
------

Registration.Sample/Registration.Sample-AddIn.dna

-4
This file was deleted.

0 commit comments

Comments
 (0)