NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
695 stars 143 forks source link

Unwanted dependency on System.Windows.Forms #424

Closed InteXX closed 2 months ago

InteXX commented 2 months ago

Is there any way to bypass the dependency on System.Windows.Forms in NetOfficeFw.Outlook, e.g. for a Console App?

jozefizso commented 2 months ago

No.

InteXX commented 2 months ago

For those watching, I was able to address this issue by modifying my console app's project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <UseWindowsForms>true</UseWindowsForms> <!-- Add this -->
    <RootNamespace>ConsoleApp1</RootNamespace>
    <TargetFramework>net8.0-windows</TargetFramework> <!-- Must target Windows -->
  </PropertyGroup>

</Project>

With that in place, I could do this:

Imports System.Windows.Forms

Public Module Program
  Public Sub Main(args As String())
    Dim form As New Form
  End Sub
End Module