-
Notifications
You must be signed in to change notification settings - Fork 67
DiagnosticSource.dll not found exception in RoleEnvironment.Changed #613
Comments
So this will repro for the Application Insights SDK for FW 4.0 as well? It looks like a design flaw of diagnostics source. Should we keep using CallContext at all? |
Or perhaps store the string instead of type in CallContext? |
Another question - is there anything that can tell "do not deserialize"? How |
Yes. it should repro on NET4.0 for It makes sense to store a string in the CallContext, however, it would not work well with Activity. Another approach may be to avoid supporting Activity/OperationContextForCallContext outside of the appdomain by just using slot specific to appdomain. I would prefer this one. |
I will check.
HttpContext.Current is not in the logical call context. It's in synchronization context and never leaves AppDomain. |
Make |
@pharring
That seems to be wrong: There is no problem with serialization, the problem is that DiagnosticSource dll where |
For locating the required assembly: |
those AppDomains are controlled by IIS, so I doubt there is anything we can do, but I will check if there are some useful configuration options. |
Glimpse had the same issue #632. There was a suggestion to wrap Activity with ObjectHandler. I've played with it and it does the trick. |
Nice find. That'll work. |
Fixed in stable version of Diagnostic Source |
@AlexBulankou Are you referring to 4.4.0 (stable)? I am still receiving this exception in an Application Insights project using 4.4.0. It only occurs using |
@AlexBulankou @ekumlin |
The Thanks! |
I am seeing this error ("Type is not resolved for member") in a bit different scenario. I think in my case the correct solution would be to drop the CallContext before entering the second AppDomain. Do you know how to achieve that? I am guessing that I would need to create a Task to create a child context, and then clear the Activity in CallContext by name, and hope that when returning to the Task caller it will be restored. What do you think? |
Upgrading to the stable |
@TripleEmcoder this issue affects any cross AppDomain calls. I suggest that you use latest 4.5.0-preview of DiagnosticSource from dotnet myget feed: https://dotnet.myget.org/F/dotnet-core/api/v3/index.json @NielsFilter you are right, 4.4.1 does NOT have a fix and it is shipped in 4.5.0 |
Symptoms
When application is running in cloud service and subscribes to RoleEnvironment change events, it gets
SerializationException: Type is not resolved for member 'System.Diagnostics.Activity,System.Diagnostics.DiagnosticSource, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Assembly Binding Log Viewer/fuselogvw shows following issue:
Note that it is issexpress that could not load the DiagnosticSource assembly, so the presence of dll in the siteroot of the application does not help.
Root cause
Workarounds
Install preview DiagnosticSource package with the fix
Put DiagnosticSource dll to one of the folders where iis looks for dlls (
"%PROGRAMFILES(X86)%\IIS Express"
- IIS Express;%systemroot%\System32\inetsr
- IIS).(Carefully). If you have .NET 4.6 is installed on the dev/test/prod machines, you can manually change reference to DiagnosticSource package to net46 one in the VS by removing reference and adding new one to the
SolutionDir\packages\System.Diagnostics.DiagnosticSource.4.4.0-preview2-<latest>\lib\net46\System.Diagnostics.DiagnosticSource.dll
or by changing csproj file directly(Carefully) Before calling RoleEnvironment.Changed, clean up current activity with the following code:
while (Activity.Current != null) { Activity.Current.Stop(); }
As the downside, the first request in the instance may not be correlated with dependencies.
Also, there may be other RoleEnvironment calls that cause cross AppDomain calls, so it may not be suitable in all cases.
The text was updated successfully, but these errors were encountered: