Reputation: 915
I made an HttpModule that I'm adding to the GAC and then registering it in my web.config. I used Fody Costura to embed dependencies. The output in my bin folder consists of only one dll, one .config and one .pdb (Because all the dependencies are merged into that file.) My problem is that whenever I load the module from the GAC, it is unable to find the embeded dependencies. I have the following observations:
<modules>
<add name="MyModule" type="MyNamespace.MyModule.Module, MyNamespace.MyModule"/>
</modules>
When I load my module from the GAC, my module is unable to load dependencies. I get the following message:
Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
My module is loaded as follows:
<modules>
<add name="MyModule" type="MyNamespace.MyModule.Module, MyNamespace.MyModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7d22d90bda7ffgab, processorArchitecture=MSIL"/>
</modules>
I'm thinking that my module does not know that the dependencies are within itself. Is there any way I can tell my module to load the dependencies from the merged dll? Or anyone that can point me in the right direction? I'm a little bit lost here. Thanks!
Upvotes: 2
Views: 235
Reputation: 4730
It seems that problem is related to Newtonsoft.Json
itself.
These issues say that there is a problem with the same strong name of different Newtonsoft.Json
versions:
Newtonsoft.Json.dll release incompatible versions with same strong name #615
Newtonsoft.Json.dll release incompatible versions with same strong name #1001
So, if there is one version is already installed in GAC and you try to install another one, it won't be installed.
Assemblies that have the same strong name should be identical.
As the result, your application couldn't find required version of Newtonsoft.Json
in GAC because it's not there.
If you could try to avoid using GAC, it should solve the problem.
Upvotes: 2