Click here to Skip to main content
15,390,901 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionCan not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Alex Banar1-Apr-22 4:23
MemberAlex Banar1-Apr-22 4:23 
AnswerRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Richard MacCutchan1-Apr-22 4:38
mveRichard MacCutchan1-Apr-22 4:38 
GeneralRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Alex Banar1-Apr-22 4:42
MemberAlex Banar1-Apr-22 4:42 
GeneralRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Richard MacCutchan1-Apr-22 5:44
mveRichard MacCutchan1-Apr-22 5:44 
GeneralRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Alex Banar1-Apr-22 6:22
MemberAlex Banar1-Apr-22 6:22 
GeneralRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Richard MacCutchan1-Apr-22 6:28
mveRichard MacCutchan1-Apr-22 6:28 
GeneralRe: Can not create object of DirectorySearcher class with Visual C++ with project reference of System.DirectoryServices.dll Pin
Alex Banar1-Apr-22 6:49
MemberAlex Banar1-Apr-22 6:49 
Questionrunning Powershell from ASP.NET Core 6 Pin
Johannes B. Latzel18-Mar-22 2:20
MemberJohannes B. Latzel18-Mar-22 2:20 
I'm running an ASP.NET Core 6 application on an IIS as a Rest Api calling Powershell scripts for specific tasks. It works well from my laptop (Windows 10) but doesn't work when I'm running it on a Windows Server 2019 Version 1809 Build 17763.1935. The error tells me that it cannnot find the assembly "Microsoft.Management.Infrastructure".

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Das System kann die angegebene Datei nicht finden.
File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'


"Das System kann die angegebene Datei nicht finden." = "File not found."

Did anyone encounter that problem too? The server has the following things installed:
Microsoft .NET 6.0.3 - Windows Server Hosting
Microsoft .NET Runtime - 6.0.3 (x64)
Microsoft .NET Runtime - 6.0.3 (x86)
Microsoft .NET SDK 6.0.201 (x64)
Microsoft ASP.NET Core 6.0.3 - Shared Framework (x64)
Microsoft ASP.NET Core 6.0.3 - Shared Framework (x86)
Microsoft Visual C++ 2015-2019 Redistributable (x64) - 14.28.29913
Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.28.29913
IIS 10.0
Windows PowerShell 5.1
PowerShell 7.2.1


Now to test if it is the server setup missing something I wrote a little .net console application with this code
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using Microsoft.PowerShell;

var initialSessionState = InitialSessionState.CreateDefault();
initialSessionState.ExecutionPolicy = ExecutionPolicy.Unrestricted;
using (PowerShell powerShell = PowerShell.Create(initialSessionState))
{
    powerShell.AddCommand("whoami");
    foreach (var item in powerShell.Invoke())
    {
        Console.WriteLine(item.BaseObject.ToString());
    }
    if (powerShell.HadErrors)
    {
        throw new Exception("powershell script had errors");
    }
}


I can run this program on the server without problems. But if I copy-paste this exact code into my Api code it fails with the above error. Any ideas?
AnswerRe: running Powershell from ASP.NET Core 6 Pin
Dave Kreskowiak27-Mar-22 18:17
mveDave Kreskowiak27-Mar-22 18:17 
QuestionC# TcpListener listen forever Pin
Goga Work11-Mar-22 18:42
MemberGoga Work11-Mar-22 18:42 
AnswerRe: C# TcpListener listen forever Pin
Pete O'Hanlon11-Mar-22 20:57
mvaPete O'Hanlon11-Mar-22 20:57 
QuestionPower BI Embedded : Cant doCross Filtering selecting multiple rows on a table visual pressing CTRL Pin
Member 155547063-Mar-22 17:19
MemberMember 155547063-Mar-22 17:19 
Questionhow it works Pin
Calin Cali17-Feb-22 8:48
MemberCalin Cali17-Feb-22 8:48 
QuestionRe: how it works Pin
Calin Cali17-Feb-22 10:41
MemberCalin Cali17-Feb-22 10:41 
AnswerRe: how it works Pin
jschell17-Feb-22 10:44
Memberjschell17-Feb-22 10:44 
AnswerRe: how it works Pin
Richard MacCutchan17-Feb-22 21:35
mveRichard MacCutchan17-Feb-22 21:35 
GeneralRe: how it works Pin
Calin Cali18-Feb-22 2:17
MemberCalin Cali18-Feb-22 2:17 
QuestionPlease help with dynamic objects modeling Blazor/MVC Pin
Guillermo Perez28-Jan-22 13:53
MemberGuillermo Perez28-Jan-22 13:53 
AnswerRe: Please help with dynamic objects modeling Blazor/MVC Pin
Richard MacCutchan30-Jan-22 6:17
mveRichard MacCutchan30-Jan-22 6:17 
AnswerRe: Please help with dynamic objects modeling Blazor/MVC Pin
Richard Deeming30-Jan-22 21:48
mveRichard Deeming30-Jan-22 21:48 
GeneralRe: Please help with dynamic objects modeling Blazor/MVC Pin
Guillermo Perez31-Jan-22 11:01
MemberGuillermo Perez31-Jan-22 11:01 
Question<pre>I Have an application that shows output of cpu utilization its memory used and current date and time in console application output now i want to store this 3 things in my database how can i store it?</pre> Pin
Member 154919019-Jan-22 22:06
MemberMember 154919019-Jan-22 22:06 
AnswerRe: <pre>I Have an application that shows output of cpu utilization its memory used and current date and time in console application output now i want to store this 3 things in my database how can i store it?</pre> Pin
dan!sh 9-Jan-22 22:42
professional dan!sh 9-Jan-22 22:42 
AnswerRe: <pre>I Have an application that shows output of cpu utilization its memory used and current date and time in console application output now i want to store this 3 things in my database how can i store it?</pre> Pin
jschell17-Feb-22 10:46
Memberjschell17-Feb-22 10:46 
QuestionIncorporating values directly (as is/bytewise) into a string Pin
primem0ver28-Dec-21 10:19
Memberprimem0ver28-Dec-21 10:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.