sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Standalone exe failing to load clrcompression.dll to unzip file.

Open russellhadley opened this issue 10 years ago • 14 comments

Steps to reproduce

Build https://gist.github.com/russellhadley/63d8e4bdd856bc5e29c201cbde36c09e as a stand alone exe.

Publish to a seperate "bin" directory

Run exe in a directory with the attached Product.zip.

Expected behavior

Product.zip will be unzipped and produce a Product directory and sub directories.

Actual behavior

clrcompression.dll fails to load. Under windbg this the exception returns:

"Unable to load DLL 'clrcompression.dll': This operation is only valid in the context of an app container. (Exception from HRESULT: 0x8007109A)"

The clrcompression.dll I expect to load is in the publish directory but there some issue I'm not familiar with that is hitting the loadLibray for the dll.

This example runs fine on OSX with a dotnet of the same version as below.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-rc2-002673)

Product Information: Version: 1.0.0-rc2-002673 Commit Sha: c0aeb91d61

Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64

russellhadley avatar May 05 '16 22:05 russellhadley

@schellap @gkhanna79 @ericstj it's not clear to me where the associated warning is coming from. Can any of you shed some light on this?

TheRealPiotrP avatar May 06 '16 00:05 TheRealPiotrP

I took a look at this with @russellhadley and noticed that the DLL was present in the folder. The host passes the right path and coreclr passes the right path to LoadLibraryExW. One thing I noticed was the clrcompression.dll comes from win10-x64. My APISets alarms went off immediately. But this is a standalone app, so forwarders are present in the app base. From the exception message, my guess is it appears this DLL is either an UWP AppX DLL or a onecore binary, causing a mismatch with the dotnet host process, which the OS doesn't allow.

schellap avatar May 06 '16 07:05 schellap

@piotrpMSFT This means that the binary was built with the AppX bit set that can only be used within the AppX container. It needs to have that flag unset. @weshaggard PTAL.

gkhanna79 avatar May 06 '16 13:05 gkhanna79

From @ericstj in https://github.com/aspnet/dnx/issues/3378#issuecomment-200004525

win10 - contains API set dlls since almost all are inbox. Right now this RID should only be used by UWP apps since there is a case with CLRCompression where we package the appx DLL under this RID.

Quick Side Question: Is that guidance still in effect for RC2 release and apps destined for WS 2016/Nano/Win10 that are web apps that will be running under IIS?

I'm partially asking for my own apps, but this is the advice we're giving on JabbR to those interested in creating self-contained apps (stick with win81-x64). There is still no official sample of a self-contained app that we can track https://github.com/aspnet/cli-samples/issues/36.

guardrex avatar May 06 '16 14:05 guardrex

@russellhadley, this line seems like the cause:

https://github.com/russellhadley/mcgutils/blob/master/src/cijobs/project.json#L21

Could you please change it to win7-x64 and give it a shot? In your PJ, you are effectively saying your app will run only on win10 (and potentially above) machines.

schellap avatar May 06 '16 15:05 schellap

@schellap I can confirm that win81-x64 and win7-x64 works. It was confusing to me since I think that I just used the dotnet --info to grab the rid for the machine I was on. Where should I have gotten this guidance? (for standalone command line exe)

russellhadley avatar May 06 '16 16:05 russellhadley

@ericstj, @weshaggard I thought we fixed this in the Compression package? Only "aot" runtimes should get the AppX version of the native DLL.

mellinoe avatar May 06 '16 16:05 mellinoe

I think @ianhays fixed it recently with PR https://github.com/dotnet/corefx/pull/7840.

weshaggard avatar May 06 '16 16:05 weshaggard

Yeah, I moved the AppX clrcompression to lib/netcore50 so it shouldn't be restoring on non-aot runtimes.

Either way though the RID used should be win7-x64

ianhays avatar May 06 '16 16:05 ianhays

win10-x64 should be fine, unless I'm missing something. You should only get the AppX version if you target netcore50.

mellinoe avatar May 06 '16 16:05 mellinoe

win10-x64 should be fine, unless I'm missing something. You should only get the AppX version if you target netcore50.

But we don't have a non-AppX version for win10, so wouldn't you just not get anything?

ianhays avatar May 06 '16 17:05 ianhays

I am targeting netcore50. The commandline tools I'm building need to run across Linux, Windows, and OSX so I was trying to target the portable surface available xplat.

russellhadley avatar May 06 '16 17:05 russellhadley

I am targeting netcore50

netcore50 is the moniker used for UWP 10 apps. Even with the packaging fixes, targeting netcore50 and win10 will get you the UWP version of Clrcompression.dll

The commandline tools I'm building need to run across Linux, Windows, and OSX so I was trying to target the portable surface available xplat.

It sounds like you want to target netstandard1.5.

ianhays avatar May 13 '16 15:05 ianhays

Or, better yet. netcoreapp1.0.

thesmithee avatar May 13 '16 17:05 thesmithee