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
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
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).
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.
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
I have created a small project but the issue is still there expecially when assigning a property from code behind to the interface.
Hi,
I have read that document but extern alias do not seem to work.
(see attached screenshot)
Have you got any hints?
Thanks
Luca
It’s explained here:
https://docs.wisej.com/docs/whats-new-in-4.0/managed-graphics#namespace-collision
Please login first to submit.