我有一个将消息写入Azure ServiceBus的dll
内部异常消息:“Microsoft.ServiceBus.Messaging.NetworkDetector”的类型初始值设定项引发了异常。
内部异常Stacktrace:在Microsoft.ServiceBus.Messaging.NetworkDetector.BeginCheckConnectivity(IEnumerable 1 addresses, Int32 tcpPort, TimeSpan timeout, AsyncCallback callback, Object state)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult
1.EnumerateSteps(CurrentThreadType state)
在Microsoft.ServiceBus.Messaging.IteratorAsyncResult 1.Start()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.ConnectAsyncResult.End(IAsyncResult result, ConnectInfo& info)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject
1.CreateAsyncResult。<> c.b__5_1(CreateAsyncResult thisPtr,IAsyncResult r)
在Microsoft.ServiceBus.Messaging.IteratorAsyncResult 1.EnumerateSteps(CurrentThreadType state)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject
1.OnEndCreateInstance(IAsyncResult asyncResult)
在Microsoft.ServiceBus.Messaging.SingletonManager 1.EndGetInstance(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessagingFactory.OpenLinkAsyncResult.<>c.<GetAsyncSteps>b__35_3(OpenLinkAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult
1.EnumerateSteps(CurrentThreadType state)
内部异常消息:无法在DLL“iphlpapi.dll”中找到名为“GetPerAdapterInfo”的入口点。
内部异常Stacktrace:在System.Net.NetworkInformation.UnsafeNetInfoNativeMethods.GetPerAdapterInfo(UInt32 IfIndex,SafeLocalFree pPerAdapterInfo,UInt32&amp; pOutBufLen)
在System.Net.NetworkInformation.SystemIPv4InterfaceProperties.GetPerAdapterInfo(UInt32 index)
在System.Net.NetworkInformation.SystemIPv4InterfaceProperties..ctor(FixedInfo fixedInfo,IpAdapterAddresses ipAdapterAddresses)
在System.Net.NetworkInformation.SystemIPInterfaceProperties..ctor(FixedInfo fixedInfo,IpAdapterAddresses ipAdapterAddresses)
在System.Net.NetworkInformation.SystemNetworkInterface..ctor(FixedInfo fixedInfo,IpAdapterAddresses ipAdapterAddresses)
在System.Net.NetworkInformation.SystemNetworkInterface.GetNetworkInterfaces()
在System.Net.NetworkInformation.SystemNetworkInterface.InternalGetIsNetworkAvailable()
在System.Net.NetworkInformation.NetworkChange.AvailabilityChangeListener.Start(NetworkAvailabilityChangedEventHandler caller)
在Microsoft.ServiceBus.Messaging.NetworkDetector..cctor()
以下是脚本
$ connectionName =“AzureRunAsConnection”
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
Add-AzureRmAccount
-ServicePrincipal
-TenantId $servicePrincipalConnection.TenantId
-ApplicationId $servicePrincipalConnection.ApplicationId
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
InlineScript
{
[System.Reflection.Assembly]::LoadFrom("C:\Modules\User\TestAutomationServiceBus\Microsoft.ServiceBus.dll")
}
ls c:\modules\user\TestAutomationServiceBus
inlinescript {[Reflection.Assembly]::LoadFile("C:\Modules\User\TestAutomationServiceBus\TestAutomationServiceBus.dll")}
inlinescript{ [TestAutomationServiceBus.TestAutomationServiceBus]::Main()}
}
以上是我的剧本。 TestAutomationServiceBus.dll包含连接到ServiceBus的c#代码并添加消息
下面是c#脚本 var connectionString =“Endpoi”; var queueName =“mustang-audit-q”;
var client = QueueClient.CreateFromConnectionString(connectionString, queueName);
var message = new BrokeredMessage("This is a test message from Automation!");
//message.TimeToLive = TimeSpan.MaxValue;
//Console.WriteLine(String.Format("Message id: {0}", message.MessageId));
client.Send(message);
return message.MessageId;