System.Drawing.Common issue after upgrading to WiseJ 4

0
0

Hi,

we have just updated our project from WiseJ 3.5 (.NET Framework 4.8 + .NET 7.0) to WiseJ 4.0 (.NET 9.0) and we have this error:

CS0433 “Type ‘Font’ already exists in both System.Drawing.Common.dll and System.Drawing.Managed.dll “…

I am attaching screenshot (sorry if it is in italian).

We have read the documentation but it seems to me hard to understand and apply…

Here is my csproj:

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

<PropertyGroup>
<Version>2.0.42</Version>
<TargetFrameworks>net9.0-windows;net9.0</TargetFrameworks>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<EmbeddedResourceUseDependentUponConvention>true</EmbeddedResourceUseDependentUponConvention>
<RootNamespace>$(MSBuildProjectName.Replace(” “, “_”).Replace(“-“, “_”))</RootNamespace>
<NoWarn>CA1416</NoWarn>
</PropertyGroup>

<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableSourceLink>true</EnableSourceLink>
</PropertyGroup>

<ItemGroup Condition=”‘$(TargetFramework.TrimEnd(`0123456789`))’==’net'”>
<Reference Include=”Microsoft.CSharp” />
<Reference Include=”System.Windows.Forms”>
<Aliases>swf</Aliases>
</Reference>
<Reference Include=”System.Data.DataSetExtensions” />
</ItemGroup>

<ItemGroup>
<Compile Remove=”Controls\DateTimePicker\**” />
<Compile Remove=”Controls\ToolComponents\**” />
<Compile Remove=”Themes\**” />
<EmbeddedResource Remove=”Controls\DateTimePicker\**” />
<EmbeddedResource Remove=”Controls\ToolComponents\**” />
<EmbeddedResource Remove=”Themes\**” />
<None Remove=”Controls\DateTimePicker\**” />
<None Remove=”Controls\ToolComponents\**” />
<None Remove=”Themes\**” />
</ItemGroup>

<ItemGroup>
<Compile Remove=”Controls\IDgBindableControls.cs” />
<Compile Remove=”Controls\Lookup\ThreeLevelsSingleObjectLookupControlBinder_B.cs” />
<Compile Remove=”IValidatableControl.cs” />
</ItemGroup>

<ItemGroup>
<PackageReference Include=”ClosedXML” Version=”0.104.2″ />
<PackageReference Include=”DG.Ext.Font” Version=”2.0.2″ />
<PackageReference Include=”System.Data.SqlClient” Version=”4.9.0″ />
<PackageReference Include=”Wisej-4″ Version=”4.0.0″ />
<PackageReference Include=”Wisej-4-AceEditor” Version=”4.0.0″ />
<PackageReference Include=”Wisej-4-NavigationBar” Version=”4.0.0″ />
</ItemGroup>

<!–<ItemGroup Condition=”!$(TargetFramework.Contains(`-windows`)) And ‘$(TargetFramework.TrimEnd(`0123456789`))’!=’net'”>
<PackageReference Include=”System.Drawing.Common” Version=”$(_TargetFrameworkVersionWithoutV).0″ Aliases=”sdc” ExcludeAssets=”compile”/>
</ItemGroup>–>
<ItemGroup>
<Compile Update=”Controls\BaseUserControl\DgComplexControl.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\DataGrid\FiIltri\FiltersPopupCol.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\DocumentViewer\DgPanelAttachmentDownload.cs”>
<SubType>Component</SubType>
</Compile>
<Compile Update=”Controls\Forms\DefaultMultiLookupSearchFormAsTreeView.cs”>
<SubType>Form</SubType>
</Compile>
<Compile Update=”Controls\Forms\DefaultSimpleLookupSearchFormAsTreeView.cs”>
<SubType>Form</SubType>
</Compile>
<Compile Update=”Controls\Lookup\MultiLookupBase.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Lookup\DgComboLookup.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Lookup\ComboDgBaseLookup.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Lookup\ThreeLevelsSingleDescriptionHorizontalLookup.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Lookup\ThreeLevelsSingleDescriptionLookup.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Lookup\ThreeLevelsLookup.cs” />
<Compile Update=”Controls\NavigationBarCtrl\AreaRicerca.cs” />
<Compile Update=”Controls\NavigationBarCtrl\DgNavigationBar.cs” />
<Compile Update=”Controls\Panels\DgHierarchicalTreeViewPanel.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Panels\DgTreeViewPanel.cs”>
<SubType>UserControl</SubType>
</Compile>
<Compile Update=”Controls\Reports\frmReportDesigner.cs”>
<SubType>Form</SubType>
</Compile>
<Compile Update=”Controls\TextBox\DgTagTextBox.cs”>
<SubType>Component</SubType>
</Compile>
<Compile Update=”Properties\Resources.Designer.cs”>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<ProjectReference Include=”..\..\Utilities\DG.Security\DG.Security.csproj” />
<ProjectReference Include=”..\..\Utilities\DG.UtilityCore\DG.UtilityCore.csproj” />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update=”Properties\Resources.resx”>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Folder Include=”Controls\Acl\” />
</ItemGroup>

<ItemGroup>
<PackageReference Update=”System.Drawing.Common” Version=”9.0.4″ />
</ItemGroup>
</Project>

 

Have you got any other suggestion?

Thanks,

Luca

  • You must to post comments
0
0

Hi Luca,

thanks for your answer.

We need that library, anyway we could rewrite all the library code.

But, supposing to remove all System.Drwaing references, like I did in the screenshot and the attached code, what should we use instead of System.Drawing?

Many Thanks,

Luca

  • Levie (ITG)
    Your WisejWebApplication1 project in the sample is missing a reference to Wisej-4. Adding that should import Managed.System.Drawing in the project. The dependency is not automatically carried through the class library. HTH, Levie
  • You must to post comments
0
0

You have to remove all your references to System.Drawing.Common as indicated in the documentation.

The sample code you posted compiles without issues omce you remove the external Datagraph.Ext.Font library which is using System.Drawing.Common (which is based on GDI+ and dropped on Linux by Microsoft). That library is not available on NuGet but my guess is that it’s bringing in the System.Drawing.Common package. You can modify the NuSpec and exclude the asset (see NuSpec documentation).

  • You must to post comments
0
0

It seems to be impossible having the correct reference to Font and other System.Drawing object.

You should rename System.Drawing namespace inside System.Drawing.Managed to avoid this behaviour.

  • Levie (ITG)
    Hey Luca, there are slight deviations in how Managed.System.Drawing and the Wisej.NET framework (Wisej-4 package) is used across different target frameworks. Adding net9.0-windows as a target to your class library should resolve the issue. In general, when creating a class library for a Wisej.NET project, always include the target frameworks that are specified in your base project. Best, Levie
  • Luca Natali
    Thanks Levie, just one more question, I am deploying my app on Linux so I am wondering if requiring net9.0-windows framework (which I thought was only for the designer) could make me impossible to deploy my Linux docker container. Have you any hints ? Many Thanks Luca
  • Levie (ITG)
    Hey Luca, it won’t affect it at all, just copy the contents of the net9.0 folder under /bin instead of net9.0-windows or you can use the VS publishing tool to build the output for Linux. HTH, Levie
  • You must to post comments
0
0

hi,

I have reproduced the issue in a small project because the real one is too complex to explain, but the issue is the same.

many thanks,

Luca

  • You must to post comments
0
0

I have created a small project but the issue is still there expecially when assigning a property from code behind to the interface.

  • Julie(ITG)
    Can you please attach the project here so we can have a look at it? Delete the bin and obj files so that it is small enough to post. -Julie
  • You must to post comments
0
0

Hi,

I have read that document but extern alias do not seem to work.

(see attached screenshot)

Have you got any hints?

Thanks

Luca

Attachment
  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.