Tombatron
Tombatron

Reputation: 1347

Issue with optional nullable parameter

One of the endpoints of the API that I work on contains an optional nullable parameter provided by query string.

The endpoint is defined similar to the following example:

[HttpGet]
[Route("nullable")]
public IHttpActionResult GetAnonymousTypeDefinition([FromUri]long? i = null)
{
    return Ok();
}

A contrived and functionally useless example I admit. However, when I run this example locally and in my "dev" environment, it returns 200. However, when this code is run in my "test" environment it returns a 500 and I'm provided the following error:

Could not load type 'System.Nullable`1' from assembly 'Example.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Just to ensure that my test environment was running a version of the framework that has support for nullable types, I added another endpoint that returns Environment.Version, like so:

[HttpGet]
[Route("framework-version")]
public IHttpActionResult GetFrameworkVersion()
{
    return Ok($"{Environment.Version}");
}

The above endpoint returns the following value:

"4.0.30319.42000"

At this point I'm kind of at a loss as to what else I should check.

Any thoughts?

Upvotes: 1

Views: 175

Answers (3)

K. Berger
K. Berger

Reputation: 361

Indeed, there was an issue with how Instana's IL-rewriting process handles Nullable<T>. We provided a quick fix as soon as we were aware of the problem and knew what happened.

This being said I strongly recommend contacting our support-team to get a quick response and let us know about any issues with our components. The fix has been confirmed and will be released within the next 24 hours.

If you want to get the fix prior to that, contact the support-team and we will provide the patch to your team.

Upvotes: 3

Anders
Anders

Reputation: 11

We had the same problem with Instana. This afternoon we received two new dll's for the Instana agent. After replacing these and restarted the agent everything started to work again. Instana will release a new version of the agent that fixes this issue.

Upvotes: 1

Tombatron
Tombatron

Reputation: 1347

It turns out that we were evaluating Instana in our test environment.

One of our ops guys did the following:

Uninstalled the Instana agent and rebooted, then...

Removed Instana related registry keys from:

hklm/software/Microsoft/Fusion/GACChangeNotfification/default
hklm/software/microsoft/tracing/instana*
hklm/software/wow6432Node/microsoft/tracing/instana*

And unregistered the following DLLs:

regsvr32 /u "C:\Program Files (x86)\Instana\instana-agent\data\repo\com\instana\agent-windows-extensions\1.3.1\agent-windows-extensions-1.3.1\tracing\Instana.Profiler_x86.dll"
regsvr32 /u "C:\Program Files (x86)\Instana\instana-agent\data\repo\com\instana\agent-windows-extensions\1.3.1\agent-windows-extensions-1.3.1\tracing\Instana.Profiler_x64.dll"

Upvotes: 1

Related Questions