ANTS Profiler: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) - red-gate-ants

I'm getting the error below during the "summarizing results" after stopping profiling a w3wp.exe process. Any ideas? Thanks in advance.
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
System.IO.FileNotFoundException
at ??.?..?.?(Int32 profileeProcessID, Int32 millisecondsMax, Guid profilerClass, String profilerPath, IntPtr clientData, Int32 dataSize)
at ??.?.??(Int32 , IEnumerable`1 )
at ?.?.?()
Stack is
[Managed to Native Transition]
> RedGate.Profiler.Engine.dll!..() + 0x1035 bytes
RedGate.Profiler.Engine.dll!..() + 0x2a3 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x9b bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x4d bytes

Looks like a permissions issue - w3wp inherits ANTS' permissions. Either log in with app pool account or change app pool to be able to run under your account.

Related

SID of the target principal could not be resolved.

I delpoyed my web application (which uses LDAP) on windows server 2016. It is throwing below error. Though I am able to access same ADLDS instance using ADSI or C# console application (created utility to test connectivity). But not sure why its throwing error with web application. Please suggest.
Server Error in '/' Application.
**While trying to resolve a cross-store reference, the SID of the target principal could not be resolved. The error code is 1722.**
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.DirectoryServices.AccountManagement.PrincipalOperationException: While trying to resolve a cross-store reference, the SID of the target principal could not be resolved. The error code is 1722.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[PrincipalOperationException: While trying to resolve a cross-store reference, the SID of the target principal could not be resolved. The error code is 1722.]
System.DirectoryServices.AccountManagement.ADStoreCtx.ResolveCrossStoreRefToPrincipal(Object o) +570
System.DirectoryServices.AccountManagement.ADUtils.DirectoryEntryAsPrincipal(DirectoryEntry de, ADStoreCtx storeCtx) +133
System.DirectoryServices.AccountManagement.ADDNLinkedAttrSet.get_CurrentAsPrincipal() +86
System.DirectoryServices.AccountManagement.PrincipalCollectionEnumerator.MoveNext() +252
System.DirectoryServices.AccountManagement.PrincipalCollectionEnumerator.System.Collections.IEnumerator.MoveNext() +9
System.Linq.<SelectManyIterator>d__22`3.MoveNext() +65
System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +264
System.Linq.GroupedEnumerable`3.GetEnumerator() +72
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +63
System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection) +392
System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection) +15
Plastin.Common.Security.ADLDSClaimsProvider.SetApplicationClaims() +1012
Plastin.Common.Security.ADLDSClaimsProvider.Initialise() +174
Plastin.Common.Security.ADLDSClaimsProvider..cctor() +238
[TypeInitializationException: The type initializer for 'Plastin.Common.Security.ADLDSClaimsProvider' threw an exception.]
lambda_method(Closure , IBuilderContext ) +81
Microsoft.Practices.ObjectBuilder2.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context) +35
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) +10
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) +198
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +209
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +165
[ResolutionFailedException: Resolution of the dependency failed, type = "Plastin.Common.Security.IClaimsProvider", name = "(none)".
Exception occurred while: Calling constructor Plastin.Common.Security.ADLDSClaimsProvider().
Exception is: TypeInitializationException - The type initializer for 'Plastin.Common.Security.ADLDSClaimsProvider' threw an exception.
-----------------------------------------------
At the time of the exception, the container was:
Resolving Plastin.Common.Security.ADLDSClaimsProvider,(none) (mapped from Plastin.Common.Security.IClaimsProvider, (none))
Calling constructor Plastin.Common.Security.ADLDSClaimsProvider()
]
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) +329
Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides) +15
Microsoft.Practices.Unity.UnityContainerExtensions.Resolve(IUnityContainer container, ResolverOverride[] overrides) +72
Plastin.Common.Security.AuthenticationManager.Authenticate(String resourceName, ClaimsPrincipal incomingPrincipal) +149
Plastin.Portal.MvcApplication.Application_PostAuthenticateRequest() +70
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +21
System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +56
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +141
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Finally we fixed this issue and my apologies I am getting late to answer this question. After lots of debugging we identified that our web application was throwing this error while getting members of ADLDS group. It was unusual as same application was working on other server. So we decided to captured network traffic using Wireshark. Wireshark capture indicated that connectivity between LDAP server and application server was blocked over SMB port 445. So we get our Network team to open port 445 which fixed the issue.
This error seems very generic error and could be other reasons for this error in your scenario but using network traffic capturing tool (like wireshark) at early stage of investigation might help you to troubleshoot these kind of issue quickly.

How to track MSDTC error in NServicebus?

We got a weird error that we can't figure the cause of. It happened over 100 times in a matter of seconds and then it stopped.
Stacktrace:
System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.Transactions.TransactionException: MSDTC was unable to read its configuration information. (Exception from HRESULT: 0x8004D027) ---> System.Runtime.InteropServices.COMException: MSDTC was unable to read its configuration information. (Exception from HRESULT: 0x8004D027)
at System.Transactions.Oletx.IDtcProxyShimFactory.ConnectToProxy(String nodeName, Guid resourceManagerIdentifier, IntPtr managedIdentifier, Boolean& nodeNameMatches, UInt32& whereaboutsSize, CoTaskMemHandle& whereaboutsBuffer, IResourceManagerShim& resourceManagerShim)
at System.Transactions.Oletx.DtcTransactionManager.Initialize()
--- End of inner exception stack trace ---
at System.Transactions.Oletx.OletxTransactionManager.ProxyException(COMException comException)
at System.Transactions.Oletx.DtcTransactionManager.Initialize()
at System.Transactions.Oletx.DtcTransactionManager.get_ProxyShimFactory()
at System.Transactions.Oletx.OletxTransactionManager.CreateTransaction(TransactionOptions properties)
at System.Transactions.TransactionStatePromoted.EnterState(InternalTransaction tx)
--- End of inner exception stack trace ---
at System.Transactions.TransactionStateAborted.CheckForFinishedTransaction(InternalTransaction tx)
at System.Transactions.Transaction.Promote()
at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)
at System.Transactions.TransactionInterop.GetDtcTransaction(Transaction transaction)
at System.Messaging.MessageQueue.StaleSafeReceiveMessage(UInt32 timeout, Int32 action, MQPROPS properties, NativeOverlapped* overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, IntPtr transaction)
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionTyp
Any ideas about how we can track the cause of this error?

How to catch exception/fault where message size is larger than accepted by the service (server side)?

At first, I thought if I added an implementation of IDispatchMessageInspector, that perhaps this would intercept the message size before any checking on the limit is done. I soon found, this is not the case. The running service obviously makes sure to enforce this rule on a lower level. Now I am curious if there is a way in which I can capture such an exception on the server level and return a response to the client. Would the an implementation of IErrorHandler as a ServiceBehavior do the trick?
Maybe the more general question is: Can this be tracked at the server level?
It may also be worth noting that I am not in control of the WSDL.
The message size is verified at the lower level - at the transport level.
There isn't a easy way to catch that exception (The IErrorHandling interface provided by WCF to handle exceptions doesn't work at this level).
One way would be to create your own custom wcf transport channel (see here an example)
See below how the generated exception looks like when the quota is exceeded - you can see that this is thrown from the low level (HttpChannelListener).
<ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The maximum message size quota for incoming messages (225) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</Message>
<StackTrace>
at System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.DecodeBufferedMessageAsync()
at System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.BeginParse()
at System.ServiceModel.Channels.HttpInput.BeginParseIncomingMessage(HttpRequestMessage httpRequestMessage, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginParseIncomingMessage(AsyncCallback asynCallback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor, Action dequeuedCallback, HttpPipeline pipeline, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync()
at System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
The best you can do (and the usual way of monitoring this) is to enable logging at the message level.
http://geekswithblogs.net/mnf/archive/2008/10/03/use-wcf-message-logging.aspx
the problem is that the maxMessageSize properties must be set on both client and server. So if the message is too large to be sent or received on the client side, your server will not know about this.

NServiceBus Could not load file or assembly

I am getting the below error when i call "NServiceBus.Host.exe". The issue appears to be itextsharp.dll. I've read that i can use
"Configure.With(AllAssemblies.Except("itextsharp.dll"))... // rest of your config"
But i'm using the following sample and not sure where to add this property.
http://docs.particular.net/samples/web/asp-mvc-application/
#
Unhandled Exception: Magnum.StateMachine.StateMachineException: Exception occurr
ed in Topshelf.Internal.ServiceController1[[NServiceBus.Host.Internal.GenericHo
st, NServiceBus.Host, Version=2.6.0.1504, Culture=neutral, PublicKeyToken=9fc386
479f8a226c]] during state Initial while handling OnStart ---> System.Exception:
Exception when starting endpoint, error has been logged. Reason: Could not load
file or assembly 'file:///D:\dev\MYSITE\MYSITE.EStore\EStore.Server\bin\Debug\itexts
harp.dll' or one of its dependencies. Operation is not supported. (Exception fro
m HRESULT: 0x80131515)
at NServiceBus.Host.Internal.GenericHost.Start() in d:\BuildAgent-02\work\20b
5f701adefe8f8\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 90
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
--- End of inner exception stack trace ---
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary1.HandleException(T stateMac
hine, Event event, Object parameter, Exception exception) in :line 0
at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event,
Object parameter) in :line 0
at Magnum.StateMachine.State1.RaiseEvent(T instance, BasicEvent1 eevent, Ob
ject value) in :line 0
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised) in :line 0
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(
IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInCont
ext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMes
sage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage req
Msg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgDa
ta, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start() in d:\dev\open-source\topshel
f\src\Topshelf\Internal\ServiceCoordinator.cs:line 54
at Topshelf.Internal.Hosts.ConsoleHost.Run() in d:\dev\open-source\topshelf\s
rc\Topshelf\Internal\Hosts\ConsoleHost.cs:line 53
at NServiceBus.Host.Program.Main(String[] args) in d:\BuildAgent-02\work\20b5
f701adefe8f8\src\host\NServiceBus.Host\Program.cs:line 103
When NserviceBus host starts it tries to retrieve all types from assemblies you specify.
In the sample you provide it uses NServiceBus.Configure.WithWeb() method.
This is the same as to call NServiceBus.Configure.With(AppDomain.CurrentDomain.DynamicDirectory)
You get the excpetion because "itextsharp.dll" cannot be loaded to AppDomain (this is done by calling Assembly.LoadFrom(file.FullName) method).
To fix the issue, you may manually specify assemblies you need to scan by using one of NServiceBus.Configure.With() overloads.

WCF Application "Unable to find assembly" for SQLite

Note: This is a solved problem, but I just spend 4 hours at this issue, so I wanted to share the solution.
When I attempt to access a WCF service, the service never responds, and the event log shows the following:
An unhandled exception occurred and
the process was terminated.
Application ID: DefaultDomain
Process ID: 3180
Exception:
System.Runtime.Serialization.SerializationException
Message: Unable to find assembly
'System.Data.SQLite, Version=1.0.66.0,
Culture=neutral,
PublicKeyToken=db937bc2d44ff139'.
StackTrace: at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo
assemblyInfo, String name) at
System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String
objectName, String[] memberNames,
BinaryTypeEnum[] binaryTypeEnumA,
Object[] typeInformationA, Int32[]
memberAssemIds, ObjectReader
objectReader, Int32 objectId,
BinaryAssemblyInfo assemblyInfo,
SizedArray assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary._BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped
record) at
System.Runtime.Serialization.Formatters.Binary._BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum
binaryHeaderEnum) at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser,
Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage
methodCallMessage) at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler
handler, Boolean fCheck, Boolean
isCrossAppDomain, IMethodCallMessage
methodCallMessage) at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream
stm) at
System.AppDomain.Deserialize(Byte[]
blob) at
System.AppDomain.UnmarshalObject(Byte[]
blob)
Solution
In my case, the problem ended up being a simple incorrect database path. However, the error message in no way reflects the actual cause, so YMMV.
The reason the "bad connection string" exception didn't make it to the event log seems related to this KB article. If the connection string isn't your problem, then your best course may be to follow the steps in this article, which will cause IIS to write exceptions to the event log.