Question

If I run a unit test (mstest) I get an exception if I call assembly.GetManifestResourceNames():

The invoked member is not supported in a dynamic assembly.

This is the problematic code:

Dim assembly As Assembly = Assembly.GetAssembly(Me.GetType())
Dim names = assembly.GetManifestResourceNames()

But if I understand the documentation right, it should work and only if I use AssemblyBuilder.GetManifestResourceNames() I should get this exception.

If I try to step through the .NET sources I get the message:

There is no source available for mscorlib.dll!System.Reflection.Emit.InternalAssemblyBuilder.GetManifestResourceNames()

Why does it throw this exception? Did I miss anything?

I forget to mention that I use Moq (with the option mock.CallBase = True) in the test.

Was it helpful?

Solution

I found a workaround: If I make the procedure shared (static in c#), where 'assembly.GetManifestResourceNames()' is called, it works.

OTHER TIPS

I couldn't get it to work with just using static, but I did find another solution.

My Setup:

  1. MVC Project (website) (References 2)
  2. Logic Project (References 3)
  3. Content Library (only files)

My website called a method in the logic project, which tried to access the GetManifestResourceNames() from the content library. This resulted in the error.

I then removed the content reference from the logic project and added it directly to my website. No other changes and now it worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top