I have a DLL that has a dependency on old version of System.Net.Http.Primitives.
Due to this call to this dll results in following error in a T4 Template
Severity Code Description Project File Line
Error Running transformation: System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.GetDefaultHttpClientHandler()
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.CreatePipeline(IEnumerable`1 handlers)
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient..ctor(IEnumerable`1 handlers, Uri applicationUri, String installationId, String applicationKey)
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor(Uri mobileAppUri, Uri gatewayUri, String applicationKey, HttpMessageHandler[] handlers)
at ProjectConfig.Client.Sdk.ServiceClientFactory.CreateClient(ServiceContext context)
at Microsoft.VisualStudio.TextTemplating94605233BE6B95A7502A0E0D0103A3C2038623387426DDF6CD07E55128CF220AA59BF7AB7A33F5E6F75E73A7CECC0C89E34B7753DD4C9A424A764F106EDB782D.GeneratedTextTransformation.TransformText()
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.WindowsAzure.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Users\rajivdas\AppData\Local\Microsoft\VisualStudio\14.0\devenv.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PublicAssemblies/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/CommonExtensions/Platform/DiagnosticsHub/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 14.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///D:/Repos/ProjectConfig/v2/Samples/Contoso/Configuration/bin/Debug/System.Net.Http.Primitives.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
LOG: Attempting download of new URL file:///D:/Repos/ProjectConfig/v2/Samples/Contoso/Configuration/bin/Debug/System.Net.Http.Primitives/System.Net.Http.Primitives.DLL.
LOG: Attempting download of new URL file:///D:/Repos/ProjectConfig/v2/Samples/Contoso/Configuration/bin/Debug/System.Net.Http.Primitives.EXE.
LOG: Attempting download of new URL file:///D:/Repos/ProjectConfig/v2/Samples/Contoso/Configuration/bin/Debug/System.Net.Http.Primitives/System.Net.Http.Primitives.EXE. Contoso.Configuration D:\Repos\ProjectConfig\v2\Samples\Contoso\Configuration\TextTemplate1.tt 1
How can I fix this?
I tried to add to the app.config for this dll, but no effect.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
If you want to debug the T4:
You need to crate a configuration file "T4VSHostProcess.exe.config" in your Visual Studio path (e.g. C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE) with the appropriate assembly binding redirect.
Setting devenv.exe.config only works if not debugging.