Could not find property named - C#
Формулировка задачи:
Всем привет.
В C# я новичок.
Довелось мне работать с такой штукой как SCOM и импортировать в него паки.
Беру первый пример из интернета:
Main.cs
StaticHelpers.cs:
Получаю ошибку:
Перепробовал множество вариантов коннекта к СКОМ, за коннект отвечает эта строка:
ManagementGroup managementGroup = new ManagementGroup("localhost");
делал и так:
ManagementGroup managementGroup = new ManagementGroup.Connect("localhost");
и так:
ManagementGroupConnectionSettings mgSettings = new ManagementGroupConnectionSettings("localhost");
ManagementGroup managementGroup = new ManagementGroup(mgSettings);
и кучу всего еще.
Во всех случаях падает на строке с "....new ManagementGroup...."
Подскажите пожалуйста, что я могу делать не так?
Что вообще значит ошибка "Could not find property named"? Перевести я могу, мне бы поглубже объяснение. В классе ManagementGroup нет никаких переменных Action, так же как и в классе, от которого он наследуется(EnterpriseManagementGroup).
В общем, буду рад любой подсказке, в какую сторону копать.
class Program { static void Main(string[] args) { StaticHelpers.ImportMp(); } }
public class StaticHelpers { internal static void ImportMp() { String pack = "MyNewPack.mp"; ManagementGroup managementGroup = new ManagementGroup("localhost"); String currentDirecoty = Directory.GetCurrentDirectory(); ManagementPack mp = new ManagementPack(currentDirecoty + pack); managementGroup.ManagementPacks.ImportManagementPack(mp); } }
Class Initialization method Tests.ClassInitialize threw exception. Microsoft.EnterpriseManagement.Configuration.ExtensionException: Microsoft.EnterpriseManagement.Configuration.ExtensionException: Could not find property named Action on type System.Collections.Generic.ICollection`1[[Microsoft.EnterpriseManagement.Configuration.ManagementPackActionType, Microsoft.EnterpriseManagement.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.</Message> <StackTrace> at Microsoft.EnterpriseManagement.Configuration.ExtensionFactory.ProcessExtensionTypeMappings(ExtensionType extensionType, Type clrType, Dictionary`2 typeSpace) at Microsoft.EnterpriseManagement.Configuration.ExtensionFactory.ProcessExtensionTypeMappings(ExtensionType extensionType, Type clrType, Dictionary`2 typeSpace) at Microsoft.EnterpriseManagement.Configuration.ExtensionFactory.ComputeExtensionTypeSpace(ICollection`1 extensions) at Microsoft.EnterpriseManagement.Configuration.ExtensionRegistry.RefreshExtensionTypeSpace(Boolean forceRefresh) at Microsoft.EnterpriseManagement.Configuration.ExtensionRegistry.GetExtensions(Boolean forceRefresh) at Microsoft.EnterpriseManagement.Configuration.ExtensionRegistry.Initialize(IContainer container) at Microsoft.EnterpriseManagement.EnterpriseManagementGroupInternal.Initialize(SdkDataLayerProxyCore sdkDataLayerProxy, EnterpriseManagementConnectionSettings connectionSettings) at Microsoft.EnterpriseManagement.ManagementGroupInternal.Initialize(SdkDataLayerProxyCore sdkDataLayerProxy, EnterpriseManagementConnectionSettings connectionSettings) at Microsoft.EnterpriseManagement.EnterpriseManagementGroupInternal.Create[T](SdkDataLayerProxyCore sdkDataLayerProxy, EnterpriseManagementConnectionSettings connectionSettings) at Microsoft.EnterpriseManagement.Common.Internal.SdkDataLayerProxyCore.ConstructEnterpriseManagementGroupInternal[T,P](EnterpriseManagementConnectionSettings connectionSettings, ClientDataAccessCore clientCallback) at Microsoft.EnterpriseManagement.Common.Internal.SdkDataLayerProxyCore.RetrieveEnterpriseManagementGroupInternal[T,P](EnterpriseManagementConnectionSettings connectionSettings, ClientDataAccessCore callbackDispatcherService) at Microsoft.EnterpriseManagement.Common.Internal.SdkDataLayerProxyCore.Connect[T,P](EnterpriseManagementConnectionSettings connectionSettings, ClientDataAccessCore callbackDispatcherService) at Microsoft.EnterpriseManagement.ManagementGroup.InternalInitialize(EnterpriseManagementConnectionSettings connectionSettings, ManagementGroupInternal internals) at Microsoft.EnterpriseManagement.ManagementGroup..ctor(ManagementGroupConnectionSettings connectionSettings) at Microsoft.EnterpriseManagement.ManagementGroup.Connect(ManagementGroupConnectionSettings connectionSettings) at Tests.StaticHelpers.ImportManagementPacks(IEnumerable`1 packs) at Tests.ClassInitialize(TestContext context)
Решение задачи: «Could not find property named»
textual
Листинг программы
String pack = "MyNewPack.mp"; ManagementGroup managementGroup = new ManagementGroup("localhost"); String currentDirecoty = AppDomain.CurrentDomain.BaseDirectory;//<<<<----- ManagementPack mp = new ManagementPack(Path.Combine(currentDirecoty, pack));//<<<<<------
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д