C
C#7mo ago
soziapath

System.Private.ServiceModel not found

I've been using a library for opcua and haven't had any problems until now, didn't change anything in dependencies, but suddenly, I get the error during runtime that the System.Private.ServiceModel is not found. When I add a reference to the exact same version as the one that the error message is indicating, it is telling me that there is a conflict:
Severity Code Description Project File Line Suppression State
Error NU1605 Warning as Error: A downgrade of the "System.Private.ServiceModel" package from 4.5.3 to 4.5.1 has been detected. Refer directly from the project to the package to select a different version.
MyProject -> MyProject.Shared -> Opc.UaFx.Advanced 2.41.1 -> System.ServiceModel.Primitives 4.5.3 -> System.Private.ServiceModel (>= 4.5.3)
Severity Code Description Project File Line Suppression State
Error NU1605 Warning as Error: A downgrade of the "System.Private.ServiceModel" package from 4.5.3 to 4.5.1 has been detected. Refer directly from the project to the package to select a different version.
MyProject -> MyProject.Shared -> Opc.UaFx.Advanced 2.41.1 -> System.ServiceModel.Primitives 4.5.3 -> System.Private.ServiceModel (>= 4.5.3)
I honestly have no idea what the problem is, I've had a similiar problem before with System.IO.Ports, but that somehow dissapeared at some point. When I do a clean build without the reference to System.Private.ServiceModel, I also don't get the dll in the output directory, despite it being referenced by the other package, and if I look at older releases, the dll was always present. This has been bugging me for a whole day and the only workaround is to manually copy the dll or add the dll to the project (which in my opinion is ugly as hell) Hope somebody might know what the problem could be. Thanks in advance.
53 Replies
reflectronic
reflectronic7mo ago
is this the full error? i think there is supposed to be more text
soziapath
soziapathOP7mo ago
The only additional thing after is the project files that cause it, basically the same line as MyProject -> ... but with the .csproj suffix
reflectronic
reflectronic7mo ago
the error does not make sense. it does not show what is downgrading System.Private.ServiceModel to 4.5.1 it is uspposed to show the two different paths to System.Private.ServiceModel that resolve to different versions
soziapath
soziapathOP7mo ago
Ah, yeah, sorry my bad, didn't see the difference in there
Severity Code Description Project File Line Suppression State
Error NU1605 Warning as Error: A downgrade of the "System.Private.ServiceModel" package from 4.5.3 to 4.5.1 has been detected. Refer directly from the project to the package to select a different version.
ProjectA -> ProjectA.Shared -> AdvancedLibrary 2.41.1 -> System.ServiceModel.Primitives 4.5.3 -> System.Private.ServiceModel (>= 4.5.3)
ProjectA -> ProjectA.Shared -> System.Private.ServiceModel (>= 4.5.0.3) ProjectA [path]\ProjectA.csproj
Severity Code Description Project File Line Suppression State
Error NU1605 Warning as Error: A downgrade of the "System.Private.ServiceModel" package from 4.5.3 to 4.5.1 has been detected. Refer directly from the project to the package to select a different version.
ProjectA -> ProjectA.Shared -> AdvancedLibrary 2.41.1 -> System.ServiceModel.Primitives 4.5.3 -> System.Private.ServiceModel (>= 4.5.3)
ProjectA -> ProjectA.Shared -> System.Private.ServiceModel (>= 4.5.0.3) ProjectA [path]\ProjectA.csproj
reflectronic
reflectronic7mo ago
System.Private.ServiceModel (>= 4.5.0.3)
it seems like you meant to write 4.5.3 not 4.5.0.3 yes, the assembly version might be 4.5.0.3. but what matters here is the package version, not the assembly version the package 4.5.3 contains the assembly version 4.5.0.3. they are different for reasons
soziapath
soziapathOP7mo ago
okay, then at least that is resolved, but the question remains, why I need to add the reference in the first place, since the library has it as dependency
reflectronic
reflectronic7mo ago
i don't know
soziapath
soziapathOP7mo ago
Okay, I added it as reference with Version 4.5.3, but I still don't get the dll in the output
reflectronic
reflectronic7mo ago
it shows up in my output when i reference Opc.UaFx.Advanced under runtimes/
soziapath
soziapathOP7mo ago
same for me, but not in the root output directory, which seems to be required? Still get the error unless I copy it manually to the same path as the executable
reflectronic
reflectronic7mo ago
do you not have a ProjectA.deps.json file in your build output
soziapath
soziapathOP7mo ago
I do have that dependency file and it contains the Dependency
"System.Private.ServiceModel/4.5.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "3.1.0",
"System.Reflection.DispatchProxy": "4.5.0",
"System.Security.Principal.Windows": "4.7.0"
},
"runtimeTargets": {
"runtimes/unix/lib/netstandard2.0/System.Private.ServiceModel.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.5.0.3",
"fileVersion": "4.6.26720.1"
},
"runtimes/win/lib/netstandard2.0/System.Private.ServiceModel.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.5.0.3",
"fileVersion": "4.6.26720.1"
}
}
},
"System.Private.ServiceModel/4.5.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "3.1.0",
"System.Reflection.DispatchProxy": "4.5.0",
"System.Security.Principal.Windows": "4.7.0"
},
"runtimeTargets": {
"runtimes/unix/lib/netstandard2.0/System.Private.ServiceModel.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.5.0.3",
"fileVersion": "4.6.26720.1"
},
"runtimes/win/lib/netstandard2.0/System.Private.ServiceModel.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.5.0.3",
"fileVersion": "4.6.26720.1"
}
}
},
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
I think that would be too much work to pseudonymize all the names while still keeping it functional^^
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\..\..\bin</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<UseWPF>True</UseWPF>
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
<PackageReference Include="System.Private.ServiceModel" Version="4.5.3" />
<PackageReference Include="pythonnet" Version="3.0.3" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.3.0.49" />
<PackageReference Include="Syncfusion.Themes.Metro.WPF" Version="20.3.0.49" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
</ItemGroup>


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

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\..\..\bin</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<UseWPF>True</UseWPF>
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
<PackageReference Include="System.Private.ServiceModel" Version="4.5.3" />
<PackageReference Include="pythonnet" Version="3.0.3" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.3.0.49" />
<PackageReference Include="Syncfusion.Themes.Metro.WPF" Version="20.3.0.49" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
</ItemGroup>


</Project>
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
i am certainly able to load it
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
</ItemGroup>

</Project>
using System.Collections.Generic;

Console.WriteLine("Hello World!");

var m = new SynchronizedCollection<int>();
m.Add(100);

Console.WriteLine(string.Join(',', AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name)));
using System.Collections.Generic;

Console.WriteLine("Hello World!");

var m = new SynchronizedCollection<int>();
m.Add(100);

Console.WriteLine(string.Join(',', AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name)));
prints out System.Private.ServiceModel among other things
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
yes, it works fine
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
what is the call stack when you hit this file not found error
soziapath
soziapathOP7mo ago
Ah, sorry, this was the ProjectA.Shared, this is the projectA.csproj:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<BaseOutputPath>..\..\..\bin</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ProjectA.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="MVTec.HalconDotNet-Windows" Version="22112.0.0" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.3.0.49" />
<PackageReference Include="Syncfusion.Themes.Metro.WPF" Version="20.3.0.49" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<BaseOutputPath>..\..\..\bin</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\ProjectA.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="MVTec.HalconDotNet-Windows" Version="22112.0.0" />
<PackageReference Include="Syncfusion.Shared.WPF" Version="20.3.0.49" />
<PackageReference Include="Syncfusion.Themes.Metro.WPF" Version="20.3.0.49" />
</ItemGroup>

</Project>
Ah, is just replaced the sensitive stuff with bullshit and let chatgpt make it pretty, guess it replaced opcua as well. AdvancedLibrary is opc.uafx.advanced
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
the restore error has been fixed but there is still a file not found error at runtime
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
I'll try to see if i can get a stacktrace
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
Not my decision sadly, company uses that and would probably break shit it we updated to a newer version
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
Honestly, I'm still pretty new to C# in general, never had the time to really understand all the ins and outs, since I had to jump straight into the project... Stack Trace seems to be pretty empty...
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
soziapath
soziapathOP7mo ago
yeah, mostly external code it seems
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
yes, the external code is what matters here
reflectronic
reflectronic7mo ago
ok. well, nothing seems suspicious there it is possible to debug this further but i think it will be easier to try this: delete the reference to System.Private.ServiceModel instead, add a reference to
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
the newer version of the package is put together in a less unconventional way, so whatever is causing this issue might not have a chance to do the wrong thing
soziapath
soziapathOP7mo ago
Thanks a lot for the help! Will try that now... Still the same error
reflectronic
reflectronic7mo ago
that System.Private.ServiceModel is not found? that does not make sense. it does not exist with the 6.0.0 version of the package
soziapath
soziapathOP7mo ago
It still seems to be part of the dependencies in the deps.json, I deleted the build folder, output folder, did a clean and a clean build, still seems to appear in the deps.json
reflectronic
reflectronic7mo ago
it is definitely not part of mine. the word private doesn't show up anywhere
<BaseOutputPath>..\..\..\bin</BaseOutputPath>
just to be clear, the two build outputs do not go into the same folder, right
soziapath
soziapathOP7mo ago
they do go to the same folder
reflectronic
reflectronic7mo ago
._. that is entirely wrong tht should never be done it would explain these inexplicable issues, because it just means one build will randomly overwrite the other based on which one happens first
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
at the very least, it needs to be explained what it's for...
soziapath
soziapathOP7mo ago
honestly, i think nobdody really had any idea what they were doing. I just recently started working at the company and it's honestly baffling, even my private projects have better structure, testing, etc. But since I'm still pretty new to c#, .net, msbuild etc, I'm not really in for improving things, just wanna finish the current project and then maybe/hopefully have some time for general improvements.
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
i guess, i just don't understand how this part is possible here is my project:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>

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

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Opc.UaFx.Advanced" Version="2.41.1" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.0.0" />
</ItemGroup>

</Project>
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
and here is the only reference to System.ServiceModel in my deps.json:
"System.ServiceModel.Primitives/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-uGyB5FMdwiBmSgJtB0x9mWUuGYj/RbXjh8I6FtsZmUAVcFc6qjOasHPHnflHUk+Qqbx7cAFugDUa2HFRtDe1QA==",
"path": "system.servicemodel.primitives/6.0.0",
"hashPath": "system.servicemodel.primitives.6.0.0.nupkg.sha512"
}
"System.ServiceModel.Primitives/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-uGyB5FMdwiBmSgJtB0x9mWUuGYj/RbXjh8I6FtsZmUAVcFc6qjOasHPHnflHUk+Qqbx7cAFugDUa2HFRtDe1QA==",
"path": "system.servicemodel.primitives/6.0.0",
"hashPath": "system.servicemodel.primitives.6.0.0.nupkg.sha512"
}
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
reflectronic
reflectronic7mo ago
do you have System.ServiceModel.Primitives/6.0.0? if you do not have System.ServiceModel.Primitives/6.0.0, and you are sure you added the right package reference, then are you sure you are looking at the right deps.json file?
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server