question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Management unavailable when targeting net46

See original GitHub issue

I have a multi-targeting project with <TargetFrameworks>netstandard1.3;net46</TargetFrameworks> set.

I have some code which does a WMI query. I’d like to conditionally compile it for NET46, and do something else for NETSTANDARD1_3, but apparently I can’t use System.Management.ManagementObjectSearcher, System.Management.ManagementObject and friends in either framework.

Am I missing something?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dsplaistedcommented, Mar 21, 2017

@yaakov-h Do you also have a referennce to System.Management? A basic project would look something like this:

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

  <PropertyGroup>
    <TargetFrameworks>netstandard1.3;net46</TargetFrameworks>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <AssemblySearchPaths>$(AssemblySearchPaths);{GAC}</AssemblySearchPaths>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <Reference Include="System.Management" />
  </ItemGroup>

</Project>
0reactions
yaakov-hcommented, Mar 23, 2017

@dsplaisted a-ha, that’s what I was missing. I wasn’t sure how to add a reference like that, the IDE provides nothing for that.

That works, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to use System.Management.dll in Dot Net Core
Guess you have to define machine you are interacting with and then try to invoke native calls for such information (PInvokes for win...
Read more >
Microsoft .NET Framework Repair Tool is available
Repair operation can be optionally scoped to target a set of specified product baselines. If this option is not specified, the tool will...
Read more >
Error MSB4018 when building ReactReduxSpa ...
After upgrading to current Visual Studio 2017RC build I keep getting build errors (MSB4018, FileNotFoundException, System.IO.
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
A 15-second guide and 15-minute walk through. You have a .Net Core project, whether a netstandard library, or a netcore app, and you'd...
Read more >
NuGet — Targeting both .NET Standard and the .NET ...
NET Core versions of all of our libraries I decided to take a look at the story around creating packages which could target...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found