# Mongo Instrumentation on .NET Framework

**URL:** <https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566>\
**Category:** APM\
**Tags:** dotnet\
**Created:** [August 5, 2021, 4:57pm UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566 "2021-08-05T16:57:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntp](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@ntp](https://discuss.elastic.co/u/ntp)\
**Post date:** [August 5, 2021, 4:57pm UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566/1 "2021-08-05T16:57:30Z")

</div>

I'm using the latest Elastic agent (1.11) on .NET Framework, but having issues trying to instrument Mongo. Despite having MongoDb.Driver(+.Core) installed in the libraries that I have the Elastic agent installed in, when I try to add the subscriber I get this issue. The Mongo version is \>2.4.4.

```auto
Could not load file or assembly 'MongoDB.Driver.Core, Version=2.4.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

```

Has anyone successfully gotten the Mongo instrumentation to work in .NET Framework?

Thanks!

---

<div class="post-metadata">

**Author:** ![ntp](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@ntp](https://discuss.elastic.co/u/ntp)\
**Post date:** [August 10, 2021, 4:08pm UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566/2 "2021-08-10T16:08:57Z")

</div>

Any advice, still stuck on this same issue. Thanks!

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 11, 2021, 1:47am UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566/3 "2021-08-11T01:47:16Z")

</div>

Hi @ntp,

There will be a problem on .NET Framework related to [Strong-named assemblies](https://docs.microsoft.com/en-us/dotnet/standard/assembly/strong-named).

**All** the Elastic APM agent assemblies are strong-named, but the MongoDB driver assemblies are not, which is a problem on .NET Framework, where a strong-named assembly can only use types from other strong-named assemblies. The MongoDB integration is tested on .NET Core but not .NET Framework, which would have caught this.

There are a couple of options I can propose at this stage, which I appreciate may not be feasible for you, but nevertheless will put them here:

1. Strong-name the MongoDB assemblies. The [`elasticapm.snk`](https://github.com/elastic/apm-agent-dotnet/tree/master/build) used to strong name the Elastic.Apm assemblies is checked into the repository, which could be used, or can generate your own with [sn](https://docs.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool).

2. If possible, use .NET Core, which doesn't enforce the same strong-naming constraints as .NET Framework.

Going forward, an option that we can investigate is instrumenting MongoDB through a CLR profiler approach, which would work with MongoDB assemblies that are not strong-named. We're looking at a profiler based approach for instrumenting other libraries already (I don't have timelines I can share, I'm afraid), so using to instrument MongoDB too would work around the strong-naming problem.

---

<div class="post-metadata">

**Author:** ![ntp](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@ntp](https://discuss.elastic.co/u/ntp)\
**Post date:** [August 11, 2021, 7:01pm UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566/4 "2021-08-11T19:01:05Z")

</div>

Thanks so much for the answer @forloop. We're working on migrating to .NET Core, but it's been a slow process. Sounds like our best option is to just wait until that migration is complete. Thanks again for all the information.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 1, 2021, 3:01pm UTC](https://discuss.elastic.co/t/mongo-instrumentation-on-net-framework/280566/5 "2021-09-01T15:01:12Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
