-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using Extensibility; | ||
|
||
namespace NetOfficeSamples | ||
{ | ||
[ComVisible(true)] | ||
[Guid("9A205EF3-1BFD-4B72-82D0-BC7CC3CF9697")] | ||
[ProgId("NetOfficeSamples.Net5Addin")] | ||
public class Net5Addin : IDTExtensibility2 | ||
{ | ||
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) | ||
{ | ||
Trace.WriteLine($"Addin connected to application. Mode: {connectMode}"); | ||
var type = application.GetType(); | ||
var name = type.FullName; | ||
var isCom = Marshal.IsComObject(application); | ||
|
||
try | ||
{ | ||
var unknown = Marshal.GetIUnknownForObject(application); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Trace.TraceError($"Marshal failed. {ex}"); | ||
} | ||
} | ||
|
||
public void OnDisconnection([In] ext_DisconnectMode removeMode, [In, MarshalAs(29, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array custom) | ||
{ | ||
Trace.WriteLine($"Addin disconnecting from application. Mode: {removeMode}"); | ||
} | ||
|
||
public void OnAddInsUpdate([In, MarshalAs(29, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array custom) | ||
{ | ||
} | ||
|
||
public void OnStartupComplete([In, MarshalAs(29, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array custom) | ||
{ | ||
Trace.WriteLine($"Addin startup completed."); | ||
} | ||
|
||
public void OnBeginShutdown([In, MarshalAs(29, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array custom) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0-windows</TargetFramework> | ||
<EnableComHosting>true</EnableComHosting> | ||
<Platforms>x86</Platforms> | ||
<PlatformTarget>x86</PlatformTarget> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'"> | ||
<DebugType>full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Extensibility"> | ||
<HintPath>C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\extensibility.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="register-addin.cmd"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
C:\Windows\SysWOW64\regsvr32.exe /s Net5Addin.comhost.dll | ||
|
||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.Net5Addin" /f /v FriendlyName /t REG_SZ /d ".NET 5 Addin" | ||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.Net5Addin" /f /v Description /t REG_SZ /d "Sample addin running in .NET 5." | ||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.Net5Addin" /f /v LoadBehavior /t REG_DWORD /d 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters