-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DLL prop logic in Microsoft.Diagnostics.Tracing.TraceEvent.props and TraceEvent.csproj #814
Comments
I think that @eerhardt knows how to solve this problem or knows the person that knows. But he is OOF until 2nd of January. |
I am in no super-hurry, we can wait until Jan. |
Maybe the below will already be covered by the work outlined here, but in case not, There's an additional problem that exists when PerfView and related TraceEvent binaries are co-located in the same directory. The scenario is that I own an app, that relies on both PerfView and TraceEvent so when my app deploys, those deploy with it. PerfView has custom This means that if PerfView and TraceEvent (+ OSExtensions, FastSerialization, etc) are in the same folder, PerfView may have some of it's dependencies auto resolved to what is along side it and not rewritten to the unpacked location. |
@suprak, Your scenario is a known issue, but is not easy to fix because the NORMAL .NET lookup logic is what is kicking in. If you are using a compatible TraceEvent package (should almost always be the case, since PerfView mostly does not care), then there really is not a problem (PerfView may not be using the one it unpacked, but it is using one that will work). I don't know of a fix for this. (In particular the changes we are envisioning above will not fix it). |
@vancem Wouldn't just moving to use the |
@suprak, There may be tricks that I don't know, but AssemblyLoad is called AFTER an assembly is loaded (thus it is too late). As such it does not have any mechanism for influencing the loading of things. It turns out that predictability (ability to determine which DLL is loaded without running the code), is an important characteristic in the runtime so I don't think you will find a easy of doing what you want. |
@vancem You're right, I misread the documentation. Maybe another option is instead of waiting for CLR to kickoff assembly resolution, we could load the dependencies using reflection from the unpack location? I think our particular issue wasn't as obvious in the past because PerfView's version of the dependency used to be something like |
Assembly loading is trickier than it seems because there different 'contexts' (sets of loaded assemblies), and loading with LoadFrom is different than loading with normal loads. While I don't rule out a solution here I am actually pretty pessimistic in the ability to OVERRRIDE loading from the local directory (which is what you want). Feel free to experiment, but keep in mind that this is a pretty rare issue, so I don't want to do major surgery or unnatural things to fix this. |
I worked "around" this by snapping the TraceEvent version to the same one used by the version of PerfView we rely on. Hopefully this will help ensure maximum compatibility. In the future, we may have to sandbox either PerfView or TraceEvent from each other, if we need to safely rev the versions. |
Sorry - I totally missed this thread while I was out and just found it in my inbox. Issue 1 above
The MSBuild way of getting COM PIA types embedded is to add a Issue 2 above
Agreed. That seems like a simple enough fix - add a Native assembly loading
On .NET Core you can write your own |
Some more info on Issue 1: I learned that NuGet added a feature for this. See https://github.com/NuGet/Home/wiki/Embed-Interop-Types-with-PackageReference. And the corresponding issue to uptake this new feature in the SDK: dotnet/sdk#2732. |
In preparing PR #813 for issue #755 I have found that logic for dealing with DLL deployment is fragile and ad-hoc. This issue tracks cleaning this up in a better way.
Here is what I have learned.
We have 5 DLLs associated with the TraceEventPackage.
As well as two native DLLs. KernelTraceControl.dll and msdia140.dll (which are architecture specific). This package preserves the illusion that the package is architecture independent by deploying all architectures (well x86, and amd64) and loading the appropriate one at runtime.
However currently two issues are being worked round in TraceEvent.csproj (when building the TraceEvent Dlls locally and Microsoft.Diagnostics.Tracing.TraceEvent.props (when unpacking the nuget package). They are
This issue is to fix this. Currently the logic is very subtle (which is why I am documenting it here).
Running DLLs from the Nuget cache is a questionable thing in general and in V3.0 we seem to be moving away from it.
The ideal situation (in my opinion) is to get embedding to work (fix issue 1) and put in logic that copies the DLLs to the target location for old 1.* and 2.* runtimes and it just works for V3.0
The text was updated successfully, but these errors were encountered: