question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflict with Microsoft EventRegister Tool

See original GitHub issue

I have a WebAPI project. I installed Microsoft EventRegister Tool (https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.EventRegister/1.1.11-beta) in it. I also installed Swashbuckle in the project. So far so good. But if I implemented a class which inherits from IOperationFilter in my project, I even can’t build my project successfully. I got the following error message:

Error 1 Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

And in the Output panel of VS, I can see this error:

1>EXEC : error : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. 1> LoaderException: 1> System.TypeLoadException: Method ‘Apply’ in type ‘EventRegisterTestingSwashbuckle.ComplexTypeQueryParamFilter’ from assembly ‘EventRegisterTestingSwashbuckle, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ does not have an implementation.

Here is my code of the filter:

public class ComplexTypeQueryParamFilter : IOperationFilter
{
    public void Apply(Operation operation, DataTypeRegistry dataTypeRegistry, ApiDescription apiDescription)
    {
    }
}

I found that EventRegister add the following sentence in my project file:

<Import Project="..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.11-beta\build\Microsoft.Diagnostics.Tracing.EventRegister.targets" Condition="Exists('..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.11-beta\build\Microsoft.Diagnostics.Tracing.EventRegister.targets')" />

If I remove it, then I can build the project successfully and seems everything goes well. I have no idea why this happens. Do you have any thoughts on this?

Thanks, Peter

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
PeterZongcommented, May 26, 2016

I sent an email to the owner of EventRegister and got the answer from him. I paste his reply below:

_EventRegister as part of its build rules uses reflection on the built assembly to look for EventSources so that it can do validation on them. If you are not using the windows Event log as a target of your event source you do not strictly need this build time process (it just detects problems with your EventSource sooner).

As part of that reflection use, it tries to load the build assembly, and that is where the error is happening. Swashbuckle is likely doing ‘tricky’ things that make loading problematic.

One simple work-around is to simply turn off the build time rules (which is what you have done below). A cleaner way of accomplishing the same thing is to only use the EventSource.Redist Nuget package (which does not even include EventRegister) instead of the full EventSource package in your application.

Event simpler, is that if you can use the version built into the .NET Runtime (since V4.5), then this too will avoid the problem.

This issue (that in general the ability to load an assembly for inspection may be problematic), is a known issue. We know how to solve it in the long term, but in the short term you need work around it._

0reactions
maperrcommented, May 26, 2016

Thanks for replying Peter

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conflict with Microsoft EventRegister Tool · Issue #133
I have a WebAPI project. I installed Microsoft EventRegister Tool (https://www.nuget.org/packages/Microsoft.Diagnostics.Tracing.
Read more >
how can i remove event's conflict
A component version required by the application conflicts with another component version already active. Conflicting components are:.
Read more >
EventRegister function (evntprov.h) - Win32 apps
Registers an ETW event provider, creating a handle that can be used to write ETW events.
Read more >
how can i diagnose a software conflict.
If the scan finds something, before clicking clean, click 'Tools' - 'Options' and check all the boxes, click 'OK', then click clean. Also,...
Read more >
Resolve merge conflicts in Visual Studio
When you merge one branch into another, file changes from commits in one branch can conflict with the changes in the other.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found