lextudio / sharpsnmplib

Sharp SNMP Library- Open Source SNMP for .NET
https://sharpsnmp.com
MIT License
356 stars 152 forks source link

Unable to run snmptrapd in vb.net 2010 #241

Closed lextudio-support closed 3 hours ago

lextudio-support commented 3 hours ago

Hi I am having the same issue as for 7214 with vb.net sample while compiling. I only know vb.net but dont know how to handle this issue. Your valuable input and help required. I am using the latest build 8e590e884d7f

Thanks in advance.

-----Error Details-------------------------------------------------------------------- System.InvalidOperationException was unhandled Message=Configuration is incorrect, the type Lextm.SharpSnmpLib.Security.User does not have a constructor that takes parameters named name, authentication, authenticationPhrase, privacy, privacyPhrase. Source=Microsoft.Practices.Unity.Configuration StackTrace: at Microsoft.Practices.Unity.Configuration.ConstructorElement.GuardIsMatchingConstructor(Type typeToConstruct, ConstructorInfo ctor) at Microsoft.Practices.Unity.Configuration.ConstructorElement.GetInjectionMembers(IUnityContainer container, Type fromType, Type toType, String name) at Microsoft.Practices.Unity.Configuration.RegisterElement.<>cDisplayClass1.b0(InjectionMemberElement m) at System.Linq.Enumerable.d142.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Microsoft.Practices.Unity.Configuration.RegisterElement.ConfigureContainer(IUnityContainer container) at Microsoft.Practices.Unity.Configuration.ContainerConfiguringElement.ConfigureContainerInternal(IUnityContainer container) at Microsoft.Practices.Unity.Configuration.ContainerElement.<>cDisplayClass1.b__0(ContainerConfiguringElement element) at Microsoft.Practices.ObjectBuilder2.EnumerableExtensions.ForEach[TItem](IEnumerable1 sequence, Action1 action) at Microsoft.Practices.Unity.Configuration.ContainerElement.ConfigureContainer(IUnityContainer container) at Microsoft.Practices.Unity.Configuration.UnityConfigurationSection.Configure(IUnityContainer container, String configuredContainerName) at Microsoft.Practices.Unity.Configuration.UnityContainerExtensions.LoadConfiguration(IUnityContainer container, UnityConfigurationSection section, String containerName) at Microsoft.Practices.Unity.Configuration.UnityContainerExtensions.LoadConfiguration(IUnityContainer container, String containerName) at snmptrapd.Program.Main(String[] args) in C:\sharpsnmplib\Samples\VB.NET\snmptrapd\Program.vb:line 39 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

-------End Error Details --------------------

-----Start of the code used-------------------------------------------

Imports System.Net Imports Lextm.SharpSnmpLib Imports Lextm.SharpSnmpLib.Pipeline Imports Lextm.SharpSnmpLib.Security Imports Lextm.SharpSnmpLib.Messaging Imports Microsoft.Practices.Unity Imports Microsoft.Practices.Unity.Configuration

Module Program Private m_Container As IUnityContainer

Friend Property Container() As IUnityContainer Get Return m_Container

End Get Private Set(ByVal value As IUnityContainer) m_Container = value End Set End Property

Public Sub Main(ByVal args As String())

If args.Length <> 0 Then Return End If

Container = New UnityContainer().LoadConfiguration("snmptrapd")

Dim users = Program.Container.Resolve(Of UserRegistry)() users.Add(New OctetString("neither"), DefaultPrivacyProvider.DefaultPair) users.Add(New OctetString("authen"), New DefaultPrivacyProvider(New MD5AuthenticationProvider(New OctetString("authentication")))) users.Add(New OctetString("privacy"), New DESPrivacyProvider(New OctetString("privacyphrase"), New MD5AuthenticationProvider(New OctetString("authentication"))))

Dim trapv1 = Container.Resolve(Of TrapV1MessageHandler)("TrapV1Handler") AddHandler trapv1.MessageReceived, AddressOf WatcherTrapV1Received Dim trapv2 = Container.Resolve(Of TrapV2MessageHandler)("TrapV2Handler") AddHandler trapv2.MessageReceived, AddressOf WatcherTrapV2Received Dim inform = Container.Resolve(Of InformRequestMessageHandler)("InformHandler") AddHandler inform.MessageReceived, AddressOf WatcherInformRequestReceived Using engine = Container.Resolve(Of SnmpEngine)() engine.Listener.AddBinding(New IPEndPoint(IPAddress.Any, 162)) engine.Start() Console.WriteLine("#SNMP is available at http://sharpsnmplib.codeplex.com") Console.WriteLine("Press any key to stop . . . ") Console.Read() engine.[Stop]() End Using End Sub

Private Sub WatcherInformRequestReceived(ByVal sender As Object, ByVal e As InformRequestMessageReceivedEventArgs) Console.WriteLine(e.InformRequestMessage) End Sub

Private Sub WatcherTrapV2Received(ByVal sender As Object, ByVal e As TrapV2MessageReceivedEventArgs) Console.WriteLine(e.TrapV2Message) End Sub

Private Sub WatcherTrapV1Received(ByVal sender As Object, ByVal e As TrapV1MessageReceivedEventArgs) Console.WriteLine(e.TrapV1Message) End Sub

End Module

-----End of the Code Used--------------------------------------------------------------------------

Original Reported Date: 2011-05-21T16:51:55.753-07:00 Planned For Release: BigDipper (7.0) Original CodePlex ID: 7218

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Please check out our source code from the backup source code repository using Mercurial, http://code.google.com/p/sharpsnmplib/

For unknown reasons, our CodePlex hosted repository does have a lot of problems recently.

Original Posted Date: 2011-05-21T19:08:22.5-07:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Hi,

I am still getting the same error even after downloading the source code from Google repository. I am/was able to compile/run the C# snmptrapd sample but only getting issue in VB.net code. (Please See the attached).

Thanks.

Original Posted Date: 2011-05-22T09:26:28.593-07:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Finally I found the solution.. Just copy the app.xml file from C# snmptrapd folder and replace the app.xml file in vb.net snmptrapd sample. if you already compiled the project delete snmptrapd.exe.xml file from folder under Samples\VB.NET\snmptrapd\bin\Debug other wise if you recompile it will use the bad file. recompile and you are done.

Original Posted Date: 2011-05-22T11:31:35.817-07:00

lextudio-support commented 3 hours ago

Copied from CodePlex without authors:

Fixed in 0661c95af267. Will be included in 7.0.

Original Posted Date: 2011-06-05T22:17:43.103-07:00

lextudio-support commented 3 hours ago

Original Closed Date: 2011-11-16T21:00:16.01-08:00