I am trying to connect to IoTHub to provision my device.
I am in a Blazor WASM app.
I have created the Security Provider Symmetric Key via:
SecurityProvider symmetricKeyProvider = new SecurityProviderSymmetricKey(parameters.DeviceId, parameters.DeviceSymmetricKey, null);
However my next line I call:
ProvisioningTransportHandler mqttTransportHandler = new ProvisioningTransportHandlerMqtt(TransportFallbackType.TcpOnly);
I have tried it with both the TcpOnly fallback along with not passing in any fallback and both give me the same error. The exception is:
Error provisioning device: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
System.TypeInitializationException: The type initializer for 'Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt' threw an exception.
---> System.InvalidOperationException: failed to create a child event loop.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Threading.Thread.Start()
at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval, IQueue`1 taskQueue)
at DotNetty.Common.Concurrency.SingleThreadEventExecutor..ctor(IEventExecutorGroup parent, String threadName, TimeSpan breakoutInterval)
at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent, String threadName, TimeSpan breakoutInterval)
at DotNetty.Transport.Channels.SingleThreadEventLoop..ctor(IEventLoopGroup parent)
at DotNetty.Transport.Channels.MultithreadEventLoopGroup.<>c.<.cctor>b__24_0(IEventLoopGroup group)
at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
--- End of inner exception stack trace ---
at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor(Func`2 eventLoopFactory, Int32 eventLoopCount)
at DotNetty.Transport.Channels.MultithreadEventLoopGroup..ctor()
at Microsoft.Azure.Devices.Provisioning.Client.Transport.ProvisioningTransportHandlerMqtt..cctor()
Related
This has me stumped.
.NET version 4.7
Powershell 5.1
I am trying to use the : new-object System.Data.SqlClient.SqlConnection statement
to connect to a MS-SQL server.
The code connects when run as Administrator but fails when run as another user that is a member of Local Administrators group.
The user has (I think) all required SQL permissions and no SQL hardening has been done. It is sysadmin on the server both with a Windows account and a SQL account.
Using
try { new-object System.Data.SqlClient.SqlConnection }
catch { write-host $_.Exception.ToString() }
to simply catch the exception.
It returns Requested registry access is not allowed
Using ProcMon there is absolutely no difference in the registry calls what so ever between the two users except that under administrator 3 threads exit and under the user only 1.
I am not convinced it is an actual registry permission as I gave the account explicit permissions on both HKLM and HKCU in the lab.
If anyone has seen this and/or can recommend a fix please hit me up.
(The script has to run as the user account because it is called from within SQL and therefore invoked under the service account context of the SQL Server Agent)
Here is the exception:
try { new-object System.Data.SqlClient.SqlConnection }
catch { write-host $_.Exception.ToString() }
System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "0" argument(s): "The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception." ---> System
.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClien
t.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.Security.Se
curityException: **Requested registry access is not allowed.**
at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
at System.Diagnostics.PerformanceCounterLib.FindCustomCategory(String category, PerformanceCounterCategoryType& categoryType)
at System.Diagnostics.PerformanceCounterLib.IsCustomCategory(String machine, String category)
at System.Diagnostics.PerformanceCounter.InitializeImpl()
at System.Diagnostics.PerformanceCounter.set_RawValue(Int64 value)
at System.Data.ProviderBase.DbConnectionPoolCounters.Counter..ctor(String categoryName, String instanceName, String counterName, PerformanceCounterType counterType)
at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp)
at System.Data.SqlClient.SqlPerformanceCounters..ctor()
at System.Data.SqlClient.SqlPerformanceCounters..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnectionFactory..cctor()
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlConnection..cctor()
--- End of inner exception stack trace ---
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)
at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
PS SQLSERVER:>
We are hosting a site that has sitefinity, the site is crashing frequently and getting the error given below:
============================
Event code: 3012
Event message: An error occurred processing a web or script resource request. The resource identifier failed to decrypt.
Event time: 8/4/2016 1:09:19 PM
Event time (UTC): 8/4/2016 6:09:19 PM
Event ID: 9ed7856e9baa479f944599104bda8f46
Event sequence: 1265
Event occurrence: 6
Event detail code: 0
Exception information:
Exception type: HttpException
Exception message: Unable to validate data.
at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo, Boolean useLegacyMode, IVType ivType, Boolean signData)
at System.Web.UI.Page.DecryptString(String s, Purpose purpose)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
Stack trace: at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Boolean useValidationSymAlgo, Boolean useLegacyMode, IVType ivType, Boolean signData)
at System.Web.UI.Page.DecryptString(String s, Purpose purpose)
at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
+++++++++++++++++
I have already implemented the steps given in the URL:
http://www.sitefinity.com/developer-network/forums/general-discussions-/event-code-3012
Please let me know if you need any additional logs
Please advice.
Regards,
Set machine decryption key same at all application servers.
https://msdn.microsoft.com/en-us/library/w8h3skw9(v=vs.100).aspx
I am testing interaction between server and client app on single desktop and having issue with processing Array. My interface looks next
<ServiceContract>
Public Interface IMyService
<OperationContract>
Function GetData() As Array
End Interface
Server side implementation, is next
Public Function GetData() As Array Implements IMyService.GetData
Return {1, 2, 3, 4, 5, 6, 7, 8}
End Function
Client side code, is next
Shared Function GetData() As Array
Dim channel As IMyService = Nothing
Try
channel = ChannelFactory(Of IMyService).CreateChannel(New NetTcpBinding, address)
Return channel.GetData()
Finally
If channel IsNot Nothing Then
CType(channel, IClientChannel).Close()
End If
End Try
End Function
I am getting next exception upon executing Return channel.GetData(), and I don't have an issue with other interface functions that returns simple types (double, integer, etc.). My server app is self hosting WCF service.
System.ServiceModel.CommunicationException occurred
HResult=-2146233087
Message=The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9270000'.
Source=mscorlib
StackTrace:
at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
InnerException: System.Net.Sockets.SocketException
ErrorCode=10054
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
NativeErrorCode=10054
Source=System
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
InnerException:
Try to use List(Of Integer) type instead of array. It seems it's untyped (unfortunately, I am not vb dev.)
Or set a ServiceKnownType attribute:
<ServiceContract>
Public Interface IMyService
<OperationContract>
<ServiceKnownType(GetType(Integer()))>
Function GetData() As Array
End Interface
By the way to simplify the process of investigating WCF issue it's useful to add error handling:
Error handling
For you case it's exception: Type 'System.Int32[]' with data contract name 'ArrayOfint:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
We have a webservice we would like to sign an incoming request and send it further. We are using the static object of System.Security.Cryptography.RSACryptoServiceProvider and every instance is using the same static object to sign it. I read on microsoft that the static object is thread safe for this class.
Problem is that on heavy load on webservice, the signing fails with below exception:
`Exception Type: System.ObjectDisposedException
Message: Safe handle's handle field can only be set if the safe handle is not closed and has a ref count of 1.
ObjectName:
Data: System.Collections.ListDictionaryInternal
TargetSite: Void _ImportKey(System.Security.Cryptography.SafeProvHandle, Int32, System.Security.Cryptography.CspProviderFlags, System.Object, System.Security.Cryptography.SafeKeyHandle ByRef)
HelpLink: NULL
Source: mscorlib
StackTrace Information
****************************
at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)`
Newbie, please bear with me as I just started yesterday with WCF.
I am using Northwind for the data and only added Customers, Orders, Order Details and Products to the model, so nothing fancy.
When I launch the application and invoke Test, and set a breakpoint, the value for products is there and it completes without error. If I then try to invoke GetMaxQuantityByOrderID(10248), I get the error listed at bottom. Why would Test() work and the same method WITHIN Test() NOT work? I even added another (Test1(), exact same as Test except it returns string: x.ProductName, which correctly displays Queso Cabrales). It seems odd that a method that is being called within another works, but calling it directly causes an exception.
Another issue I have is that the IEnumerable GetOrders() works only if I add .ToList(). Without it (or with .AsEnumerable()), I get an error (The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.), even though lazy loading is set to False. What is the logic behind this?
IServiceTest.cs
using System.Collections.Generic;
using System.ServiceModel;
namespace WcfTestServiceLibrary
{
[ServiceContract]
public interface IServiceTest
{
[OperationContract]
IEnumerable<Orders> GetOrders();
[OperationContract]
IEnumerable<Customers> GetCustomers();
[OperationContract]
Customers GetCustomerByID(string customerID);
[OperationContract]
Orders GetOrderByID(int id);
[OperationContract]
IEnumerable<Order_Details> GetOrderDetailsByOrderID(int id);
[OperationContract]
Order_Details GetMaxQuantityByOrderID(int id);
[OperationContract]
void Test();
}
}
ServiceTest.cs
using System.Collections.Generic;
using System.Linq;
namespace WcfTestServiceLibrary
{
public class ServiceTest : IServiceTest
{
public IEnumerable<Orders> GetOrders()
{
using (var ctx = new NWEntities())
{
return (from o in ctx.Orders.Include("Order_Details.Products").Include("Customers")
select o).ToList();
}
}
public IEnumerable<Customers> GetCustomers()
{
using (var ctx = new NWEntities())
{
return (from c in ctx.Customers
select c);
}
}
public Customers GetCustomerByID(string customerID)
{
return (from c in GetCustomers()
where c.CustomerID == customerID
select c).FirstOrDefault();
}
public Orders GetOrderByID(int id)
{
IEnumerable<Orders> orders = GetOrders();
return (from o in orders
where o.OrderID == id
select o).FirstOrDefault();
}
public IEnumerable<Order_Details> GetOrderDetailsByOrderID(int id)
{
return GetOrderByID(id).Order_Details;
}
public Order_Details GetMaxQuantityByOrderID(int id)
{
Orders order = GetOrderByID(id);
return order == null ? null : order.Order_Details.OrderByDescending(x => x.Quantity).FirstOrDefault();
}
public void Test()
{
const int orderID = 10248;
var oq = GetMaxQuantityByOrderID(orderID);
var x = oq.Products;
}
}
}
Error:
An error occurred while receiving the HTTP response to http://localhost:8732/Design_Time_Addresses/WcfTestServiceLibrary/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IServiceTest.GetMaxQuantityByOrderID(Int32 id)
at ServiceTestClient.GetMaxQuantityByOrderID(Int32 id)
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
Inner Exception:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
I had a very similar issue as you did. I found out that the Entity Framework proxy that wraps around your POCO classes is by default serialized by the WCF serializer, which cannot be deserialized on the client side since the client is not aware of the EF proxy wrapper. There were two solutions that I found. The first is to set ContextOptions.ProxyCreationEnabled to false. This prevents the EF from creating proxies for your POCO objects. The second was to instruct the WCF DataContractSerializer on the server side to use the ProxyDataContractResolver to serialize as just the POCO.
The second option can be found at http://msdn.microsoft.com/en-us/library/ee705457.aspx. Since I have just discovered these solutions I can't say which I would recommend as a general practice, although I lean to the latter, since the EF queries may be re-used by other callers from time to time that may want the objects returned with the appropriate EF proxies. Anyhow I know that's late to this question, but I hope that helps others who come across this issue.
Its the .Inculde in your LINQ-Statement.
I believe the reason for this is the basicaly resulting infinite datastructure pointing to and from "one" side to the "many" side of your relationship.
This you can observe by unfolding your datastructure, setting a breakpoint at the result of your .Include query statement in the debugger...
Observation:
Orders --> many Products, each product--> Order--> many Products and so forth
I guess wcf runns into that and gets cought up in that.
To break this chain of, you can simply avoid the pointing back in your data transfer object
by adding the ignoreDataMember Attribute
In the Many-Side of your relationship... In your case the Product....
[IgnoreDataMember]
public Order OrderFatherElement { get; set; }
This way WCF will stop the serializingattempt when reaching that childnode
#microsoft.... some potential for a fix?
Greets,
Kieredin Garbaa
For the first issue try to turn on WCF tracing on your service. Second issue with IEnumerable is caused by deffered execution. Btw. do you understand difference between IQueryable<T> and IEnumerable<T>? Do you know that your GetOrders method loads all Orders, related Customers and Products into memory? Even if you want to select single order you still load all of them in the service.
Edit:
WCF tracing will show you what happend during service or client execution - it traces WCF internals and it is essential tool for WCF development. Tutorial on WCF tracing and trace viewer.
IQueryable builds expression tree which is compiled into database query so you can't execute that query (deffered execution) outside context scope (context is responsible for database connection). You have to rewrite your methods. In your case each method has to create complete query and execute that query inside context scope. Execution of query is performed by selecting single record (like FirstOrDefault()) or by converting to list.