Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't package cloud service since upgrading to DocumentDB SDK 1.6.2 #118

Open
mleyb opened this issue Apr 6, 2016 · 70 comments
Open

Can't package cloud service since upgrading to DocumentDB SDK 1.6.2 #118

mleyb opened this issue Apr 6, 2016 · 70 comments

Comments

@mleyb
Copy link

mleyb commented Apr 6, 2016

Hi - Since upgrading to SDK 1.6.2 through NuGet I am no longer able to package my Cloud Service. The packaging operation fails with the following error:

Unable to copy file "C:\Work\Av\PG\AMP\Development\Av.AMP.Platform\packages\Microsoft.Azure.DocumentDB.1.6.2\build\native\DocumentDB.Spatial.Sql.dll" to "C:\Work\Av\PG\AMP\Development\Av.AMP.Platform\Av.IC3.CloudService\obj\Release-AzureCS\Av.IC3.Roles.API\C:\Work\Av\PG\AMP\Development\Av.AMP.Platform\packages\Microsoft.Azure.DocumentDB.1.6.2\build\native\DocumentDB.Spatial.Sql.dll". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I've reverted to SDK 1.5.3 and I my package step works OK

Is this a similar problem to microsoft/TypeScript#6215 ?

I notice that the path contains two paths concatenated together in a similar way

@rnagpal
Copy link
Contributor

rnagpal commented Apr 7, 2016

@mleyb : Thanks for reporting this issue. We need some more information from you so that we can repro/diagnose this issue on our end.

  • Does the project has multiple roles?
  • Are they worker or web roles?
  • Can you send the build log which contains this error?

If you could provide simple repro steps that repro that issue that would help us verifying the fix before we update the Nuget package.

@mleyb
Copy link
Author

mleyb commented Apr 7, 2016

Our cloud service project has 5 roles - 3 web roles and 2 worker roles. However, I've been able to reproduce this issue in a vanilla project containing a single web role

Here are some repro steps:

  • Use VS2015 Update 2 and Azure SDK 2.9
  • Create a new cloud service project, containing a single web role
  • Install package Microsoft.Azure.DocumentDB version 1.6.2 latest
  • Right click cloud service project and select "Package"

Packaging fails, here's an example of the error:

Severity Code Description Project File Line Suppression State
Error Unable to copy file "C:\Work\Scratch\AzureCloudService3\packages\Microsoft.Azure.DocumentDB.1.6.2\build\native\DocumentDB.Spatial.Sql.dll" to "C:\Work\Scratch\AzureCloudService3\AzureCloudService3\obj\Debug\WebRole1\C:\Work\Scratch\AzureCloudService3\packages\Microsoft.Azure.DocumentDB.1.6.2\build\native\DocumentDB.Spatial.Sql.dll". The given path's format is not supported. AzureCloudService3 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Windows Azure Tools\2.9\Microsoft.WindowsAzure.targets 2790

@rnagpal
Copy link
Contributor

rnagpal commented Apr 7, 2016

@mleyb Thanks for sharing the repro steps!

We are preparing a fix for this issue and will do a release by Monday.

@mleyb
Copy link
Author

mleyb commented Apr 8, 2016

Awesome, thanks! :)
On 7 Apr 2016 11:03 p.m., "Rajesh Nagpal" notifications@github.com wrote:

@mleyb https://github.com/mleyb Thanks for sharing the repro steps!

We are preparing a fix for this issue and will do a release by Monday.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#118 (comment)

@rnagpal
Copy link
Contributor

rnagpal commented Apr 8, 2016

@mleyb : We fixed the issue and have published .NET SDK 1.6.3 to Nuget.

Please try installing the latest version and let us know if that fixes the issue.

@rnagpal rnagpal closed this as completed Apr 8, 2016
@mleyb
Copy link
Author

mleyb commented Apr 11, 2016

All working now - thanks a lot guys 👍

@thuru-zz
Copy link

thuru-zz commented Jun 9, 2016

@rnagpal : It seems the problem still exist in version 1.7.1

@aidanmorgan
Copy link

I appear to be having the same problem in 1.7.1 as well.

@thuru-zz
Copy link

thuru-zz commented Jun 9, 2016

@aidanmorgan : seems like you if you use the Microsoft.Azure.DocumentDB nuget in different class library project and reference it in your web project, you will not get this problem. But if you reference the Microsoft.Azure.DocumentDB nuget directly in the web project you will get this issue.

@rnagpal
Copy link
Contributor

rnagpal commented Jun 9, 2016

Thanks for reporting this. We will look into this issue and get back soon.
@thuru : If you can provide us the exact repro steps that would be great so that we can verify the fix before releasing.

@rnagpal rnagpal reopened this Jun 9, 2016
@thuru-zz
Copy link

thuru-zz commented Jun 10, 2016

I'm using VS 2015 Update 2 and I have a ASP.NET 4.6 web project. I referenced the Microsoft.Azure.DocumentDB using PackageManager console. When I build the project everything is ok, but when I run in debug mode (Any CPU) I get the following message in the yellow screen. This just happens after simply referencing the assembly in the project.

Error : Could not load file or assembly
'\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

Developer machine runs on x64 Windows 10.

The web project has following dependencies

<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
  <package id="AttributeRouting.Core" version="3.5.6" targetFramework="net451" />
  <package id="AttributeRouting.Core.Http" version="3.5.6" targetFramework="net451" />
  <package id="AttributeRouting.Core.Web" version="3.5.6" targetFramework="net451" />
  <package id="AttributeRouting.WebApi" version="3.5.6" targetFramework="net451" />
  <package id="AzureEncryptionExtensions" version="1.2.0.0" targetFramework="net46" />
  <package id="bootstrap" version="3.3.5" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net45" />
  <package id="FontAwesome" version="4.2.0" targetFramework="net451" />
  <package id="Hyak.Common" version="1.0.2" targetFramework="net451" />
  <package id="JasmineTest" version="2.2.0" targetFramework="net45" />
  <package id="jQuery" version="2.1.4" targetFramework="net45" />
  <package id="JsPubSub" version="1.0" targetFramework="net451" />
  <package id="KendoUICore" version="2016.1.112" targetFramework="net46" />
  <package id="lodash" version="4.9.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.1" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.JavaScript" version="0.15.0-build58334" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.Web" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.WindowsServer" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.0.0" targetFramework="net46" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
  <package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
  <package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net451" />
  <package id="Microsoft.Azure.DocumentDB" version="1.7.1" targetFramework="net46" />
  <package id="Microsoft.Azure.KeyVault" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net451" />
  <package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.4" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.4" targetFramework="net45" />
  <package id="Microsoft.Data.Services.Client" version="5.6.4" targetFramework="net45" />
  <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.19.208020213" targetFramework="net45" />
  <package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.0" targetFramework="net46" />
  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net45" />
  <package id="Microsoft.Owin.Security.OpenIdConnect" version="3.0.1" targetFramework="net46" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net45" />
  <package id="Modernizr" version="2.8.3" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net46" />
  <package id="Owin" version="1.0" targetFramework="net451" />
  <package id="RequireJS" version="2.1.22" targetFramework="net46" />
  <package id="RequireJS.Text" version="2.0.7" targetFramework="net451" />
  <package id="Respond" version="1.4.2" targetFramework="net45" />
  <package id="StackExchange.Redis" version="1.0.488" targetFramework="net46" />
  <package id="System.IdentityModel.Tokens.Jwt" version="4.0.0" targetFramework="net46" />
  <package id="System.Spatial" version="5.6.4" targetFramework="net45" />
  <package id="toastr" version="2.1.1" targetFramework="net45" />
  <package id="WebActivator" version="1.0.0.0" targetFramework="net451" />
  <package id="WebActivatorEx" version="2.0" targetFramework="net46" />
  <package id="WebGrease" version="1.6.0" targetFramework="net45" />
  <package id="WindowsAzure.Storage" version="6.2.0" targetFramework="net46" />

@aidanmorgan
Copy link

I have pretty much the same scenario as @thuru , however this morning I rolled back my changes and re-did them, installing the package first and the problem is no longer occurring.

@thuru-zz
Copy link

@aidanmorgan could you list the dependencies of your project ? I tried this morning same issue exists.

@thuru-zz
Copy link

When referencing the Microsoft.Azure.DocumentDB in the web project it seems to create these 2 dlls which cause the issue.

DocumentDB.Spatial.Sql.dll
Microsoft.Azure.Documents.ServiceInterop.dll

@thuru-zz
Copy link

as @mleyb mentioned version 1.5.3 works fine.

@rnagpal
Copy link
Contributor

rnagpal commented Jun 11, 2016

Working offline with Thuru to get a repro. Will update the thread once the issue is resolved.

@rnagpal
Copy link
Contributor

rnagpal commented Jun 12, 2016

@aidanmorgan : Do you have a sample project that repro'es this issue consistently? If yes, I can work with you offline to get the project and investigate further. @thuru is not able to repro it now on a new project, so my guess is that this is related to some project specific setting.

Which .NET Framework version you guys are targeting for the Web Application? If you could share the snippet of code that would try to load this assembly and fail, that would help.

@jamesbascle
Copy link

Any update on this? Also seeing the assembly load exceptions for Spatial.SQL and ServiceInterop when starting my project.

@rnagpal
Copy link
Contributor

rnagpal commented Jun 28, 2016

@jamesbascle : I was unable to repro the issue on my end so if you can provide the exact repro steps, I can try again. Which version of .NET SDK are you using?
Do you have a sample project that repro'es this issue consistently? If yes, I can work with you offline to get the project and investigate further. Which .NET Framework version you are targeting for the Web Application?

@jamesbascle
Copy link

I'm using .NET 4.5.2, and see the behavior on version of DocumentDB 1.8.0, 1.7.3, 1.6.3. I am available right now if you'd like to do a remote session. Not quite sure what the repo steps are exactly, just that when I start my project, I get the assembly load exception on those 2 DLLs.

@thuru-zz
Copy link

@rnagpal could you explain the functional requirement of those 2 assemblies in the versions above 1.5.3

@sirkirby
Copy link

sirkirby commented Jul 8, 2016

same issue for me as well. I'm using the documentdb sdk in a class library and referencing that from a console app...this happens on every startup. I'm using the latest version of the docdb sdk.

@sirkirby
Copy link

@rnagpal here is the full stack trace for the issue I'm seeing. Seems to be very similar to @thuru . .Net 4.6.1, SDK v1.8, Console app referencing a class lib installed via nuget. This happens every single time the console app loads... and we run these a lot, so it's spamming our raygun crash reporting consistently.

for Spacial.Sql:

Message: [[2016-07-15 14:41:29.678 GMT 11    ERROR 101716   AssemblyLoader.Client   ]   !!!!!!!!!! An unexpected exception occurred while attempting to load an assembly.   
Exc level 0: System.BadImageFormatException: Could not load file or assembly 'file:///D:\Users\shih\Documents\GitHub\adapt-services\src\AdaptAcquisition\bin\Debug\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
at Orleans.Runtime.AssemblyLoader.ReflectionOnlyLoadAssembly(String pathName, Assembly& assembly, String[]& complaints)]

for ServiceInterop:

Message: [[2016-07-15 14:41:30.101 GMT 11    ERROR 101716   AssemblyLoader.Client   ]   !!!!!!!!!! An unexpected exception occurred while attempting to load an assembly.   
Exc level 0: System.BadImageFormatException: Could not load file or assembly 'file:///D:\Users\shih\Documents\GitHub\adapt-services\src\AdaptAcquisition\bin\Debug\Microsoft.Azure.Documents.ServiceInterop.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
at Orleans.Runtime.AssemblyLoader.ReflectionOnlyLoadAssembly(String pathName, Assembly& assembly, String[]& complaints)]

@rnagpal
Copy link
Contributor

rnagpal commented Jul 15, 2016

@thuru @aidanmorgan @jamesbascle @sirkirby

Here is a quick update on this issue:

  1. I'm finally able to repro the missing dll issue for Interop.dll in an Azure Web Service project. We are working on a fix for this and will release an update soon. Meanwhile, if you directly reference the Nuget package for DocumentDB SDK in the Azure Web Service project, the issue gets resolved.
  2. For the BadImageFormatException: This is an issue with 1.9.0 only and we are planning to release the fix for this as well in 1.9.1. Meanwhile, you need to target x64 platform for your application to resolve this issue. If you have set the platform to x86 or AnyCPU that needs to be changed to x64.

Let me know if these workarounds work for you guys until we fix the issue.

@rnagpal
Copy link
Contributor

rnagpal commented Jul 20, 2016

@thuru @aidanmorgan @jamesbascle @sirkirby

We have released .NET SDK 1.9.1 with the fix for the first issue: Missing dll issue for Microsoft.Azure.Documents.ServiceInterop.dll and DocumentDB.Spatial.Sql.dll that most of you in the thread had reported. Please update to this version and let me know if that resolves the issue.

For the second issue, your application(whether it's a Console or Web project) needs to be 64 bit preferred. By default, VS project has AnyCPU as the target platform with "Prefer 32-bit" set to true. So if you see that exception, uncheck the "Prefer 32-bit" option in your project properties window, on the Build tab, to avoid the error. You can continue to use AnyCPU as the target platform given you have unchecked the above "Prefer 32-bit" option. If you can target x64 that works as well.

@gorkar
Copy link

gorkar commented Sep 30, 2016

Trying the DOc DB integration in a Visual studio test. The code to talk to doc db is in a separate class library referred in the Test project.

upgraded to version 1.10.0 and getting the error {"Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

I copied this file to the test out put and bin of the test project but does not work

@thuru-zz
Copy link

thuru-zz commented Oct 1, 2016

No solutions yet :( our production still runs on 1.5.3

@rnagpal
Copy link
Contributor

rnagpal commented Oct 1, 2016

@thuru I'll contact you early next week and we will resolve this and if there is still a bug we will fix it asap.

@rnagpal
Copy link
Contributor

rnagpal commented Oct 1, 2016

@gorkar We resolved this issue offline. He was missing DocumentDB.Spatial.Sql.dll in his deployment dir which is needed to load Service.Interop.dll, so if you see the error regarding unable to find/load Service Interop dll, please make sure you have both binaries in your app's bin dir.

@Fritzbraun
Copy link

I've just started getting this issue since upgrading to 1.10. We're an ASP.net core app running on full framework, and we use partitioned documentdb collections. Presumably this is now happening due to the fact that partitioned collections support direct connections (which is a feature we really want).
Given I'm ASP.net core, am I just out of luck here? Am I going to have to write my own script to copy these dlls over to the correct location?

@rnagpal
Copy link
Contributor

rnagpal commented Oct 10, 2016

@Fritzbraun We currently don't yet support DocumentDB on ASP.NET Core apps and we are currently working on it. Even you are able to copy this dll(along with DocumentDB.Spatial.Sql.dll), you may run into issues for some of the APIs that would fail on .NET Core target platform.

We're an ASP.net core app running on full framework
Do you mean that you are using ASP.Net Core project but targeting NETFX(4.5 and above)? If yes, then you would have to copy them yourself as the current tooling for .NET Core doesn't support MSBUILD targets which were doing this step on regular NETFX app.

@Fritzbraun
Copy link

Yes, we're using the dotnet tooling and associated nuget packages, but we're targeting "net462".

I added a postcompile script to copy the dlls across and that worked ok for running locally, but publishing to Azure still fails as it doesn't copy those dlls across to the staging directory. I think I might be able to get it to work using a pre or postpublish step, but I'll have to hardcode the version of DocumentDB into these steps as you can't get at them programatically.

Is there a timeline for when we can expect it to work with the .net core tooling? Could you not get around this whole issue by just making the other dlls their own nuget packages?

@kaleemxii
Copy link

kaleemxii commented Oct 18, 2016

Facing the same" Unable to load DLL 'Microsoft.Azure.Documents.ServiceInterop.dll" on.net461 with version 1.9 and 1.10 , but 1.8 is working fine. and no .net core is involved here. Are you guys aware of this scenario as well ? Using it from project.json of xproj .

Even after I copy and place the specific dll , it still throws the same error. Any workarounds ?

@rnagpal
Copy link
Contributor

rnagpal commented Oct 20, 2016

@kaleemxii Make sure you also copy the DocumentDB.Spatial.Sql.dll in the same place. I've seen that error goes away when both dlls are present. They seem to be dependent on each other.

@rnagpal
Copy link
Contributor

rnagpal commented Oct 20, 2016

@Fritzbraun We are working on the .net core support currently and should be releasing a preview next month. For now you would have to use a script to copy them due to lack of tooling. I take your feedback to have them in a separate nuget packages.

@azakhodin
Copy link

@rnagpal We are having the following error "Could not load file or assembly 'file:///C:\xxx\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest."
Both files DocumentDB.Spatial.Sql.dll and Microsoft.Azure.Documents.ServiceInterop.dll are present in the bin folder. We are on net4.5.2 and we tried versions 1.8, 1.9, and 1.10.

@aarondcoleman
Copy link

@rnagpal @azakhodin same here. We only build x64 and I can't get beyond the error:

Could not load file or assembly 'file:///C:\Repositories\Fitabase\FitabaseAPI\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

On .net452, x64, and we've got 1.10.0 installed. Any other hints how to even debug what's going on here?

@rnagpal
Copy link
Contributor

rnagpal commented Nov 16, 2016

I'm looking into this now and will update in few days. The issue is that if you are using project.json tooling this doesn't seem to work.

@aarondcoleman
Copy link

aarondcoleman commented Nov 16, 2016

@rnagpal I do not have project.json and am getting this error. I am linking to a class library which references this library, from an ASP.NET WebAPI 2 project and that is causing it. Have tried referencing the NuGet in one, and then both projects. Still get the same error. Any workarounds at all?

@aarondcoleman
Copy link

@rnagpal I was able to figure out my issue, posting here for anyone else (@thuru @aidanmorgan)? This was the stacktrace error on runtime:

[BadImageFormatException: Could not load file or assembly 'file:///C:\Repositories\Fitabase\FitabaseAPI\bin\DocumentDB.Spatial.Sql.dll' or one of its dependencies. The module was expected to contain an assembly manifest.] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +234 System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +174 System.Reflection.Assembly.LoadFrom(String assemblyFile) +54 WebActivator.PreApplicationStartCode.Start() in D:\Code\Bitbucket\WebActivator\WebActivator\PreApplicationStartCode.cs:11

Turns out WebActivator was the issue. This was a dependency on AttributeRouting package(https://www.nuget.org/packages/AttributeRouting/), and there is a known issue with updating WebActivator to a new WebActivatorEx.

This new version, WebActivatorEx that takes the place of WebActivator. Manually removing and reinstalling both WebActivatorEx and AttributeRouting fixed it. This thread was helpful: http://stackoverflow.com/questions/18325799/could-not-load-file-or-assembly-hunspellx64-dll-while-using-nhunspell-nuget-pack

@rnagpal
Copy link
Contributor

rnagpal commented Nov 20, 2016

@aarondcoleman Thanks for posting the solution!

@jamesbascle
Copy link

We're still seeing this. I'll list out all of the conditions we're running under, just in case.

Azure Web Apps; Lib Version 1.10.0; C#6; .NET 4.5.2; x64 (Project and App Service); VS2015; Autofac.WebApi2.Owin 3.3.0; Autofac.WebApi 2.3.4.0; Owin 1.0; WebActivatorEx 2.2.0

We are not using MVC at all, or the AttributeRouting package. These exceptions (for both DocumentDB.Spatial.Sql.dll and Microsoft.Azure.Documents.ServiceInterop.dll) don't seem to actually keep us from interacting with DocumentDB, but we see them in Diagnostic Tools as the first event every time we debug locally with IISExpress in VS2015, or take a memory dump from the Azure Web App service.

@Mikael-SP
Copy link

I had this issue today while running IIS on my local computer. I tried everything: manually adding the missing DLL in the bin folder, rebuilding, trying multiple versions of documentdb via nuget, building in x64 and x86, ... It was still happening even if the missing DLL files were presents.

Finally, I updated Visual Studio 2015 and azure SDK with the very latest versions and after cleaning and rebuilding my projet it started working again.

@alanmk
Copy link

alanmk commented Dec 30, 2016

I have a related issue in which a .NET 4.5.2 nuget package, that references Microsoft.Azure.DocumentDB (1.11.1), fails to install with error:

Failed to add reference to 'DocumentDB.Spatial.Sql'.

I've worked through the above with no success as yet.

@rnagpal
Copy link
Contributor

rnagpal commented Dec 30, 2016

@FaC7oR That's a different issue. What's causing the error above. Note that you don't need to reference this dll anywhere in your project(unlike Microsoft.Azure.Documents.Client.dll). This dll is needed only at runtime and just need to be binplaced along with the Client dll which if you are importing the nuget package correctly should work. What's the type of the project(Console/ASP.NET/Library) you are using? Are you doing anything with DocumentDB.Spatial.Sql which is causing this?

@alanmk
Copy link

alanmk commented Dec 30, 2016

It's a packaging problem, i.e. nuget reports this error when trying to install a custom package that I've created. More precisely:

I'm importing a class library nuget, that I've created/packaged with a dependency on DocumentDB, into another class library (a blank test project). Both target .NET 4.5.2 and have an x64 build configuration.

I'm not using DocumentDB.Spatial.Sql at all.

@alanmk
Copy link

alanmk commented Dec 30, 2016

I should also add: I'm not referencing/using DocumentDB.Spatial.Sql at all. Nuget seems to be looking for it when I install my package.

@jamesbascle
Copy link

jamesbascle commented Dec 30, 2016 via email

@alanmk
Copy link

alanmk commented Dec 30, 2016

I've managed to sort the problem. I needed to tell nuget to look for DocumentDB.Spatial.Sql explicitly, i.e. by adding the following to my nuspec file:

<references>
     <reference file="DocumentDB.Spatial.Sql" />
</references>

Would it be worth packaging the offending binary separately to keep nuget happy?

@rnagpal
Copy link
Contributor

rnagpal commented Feb 3, 2017

I want to call out if there is anyone in this thread that still has issues with the referencing/copying ServiceInterop and Spatial native dlls please open a new issue detailing the environment as this post has become too big to refer. I'll reference this link in any of the new issues created.

@thuru Did it finally worked for you? If not send me an email and we can debug it on a Skype call as you seem to be stuck with 1.6 version due to thus issue.

@BowserKingKoopa
Copy link

BowserKingKoopa commented Apr 13, 2017

I just ran into this, or something like this. I'm getting build errors: "DocumentDB.Spatial.Sql.dll' is a binary file instead of a text file" and "Microsoft.Azure.Documents.ServiceInterop.dll' is a binary file instead of a text file". I'm using the documentdb sdk 1.13.1 and referencing a nuget package that refers to it in and ASP.NET Core (Framework) app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests