在docker中找不到Windows运行时类型

时间:2018-01-17 17:43:09

标签: c# docker uwp .net-core dockerfile

我创建了一个用于读取BLE消息的.Net Core Console应用程序,并且我引用了Widows.winmd来使用BluetoothLEAdvertisementWatcher(Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcher)。我已经运行“dotnet publish -c Realease -r win10-x86”和docker build从发布文件夹映像创建成功,但我在运行容器时收到错误。我该如何解决?

Dockerfile:

int main(int argc, char *argv[]) {
    char f_out[30];
    FILE *intrare;

    ordonare_argumente(argc, argv);

    if (argc != 11)  strcpy(f_out, argv[4]);
    else strcpy(f_out, argv[8]);
    if ((intrare = fopen(argv[2], "r")) == NULL) {
        FILE *iesire = fopen(f_out, "w");
        fprintf(iesire, "Missing the input file");
    }

    for (int i = 0; i < argc; i++)
        printf("argumentul nr %d este:%s\n ", i, argv[i]);

    return(0);
}

Docker构建结果:

FROM microsoft/windowsservercore
WORKDIR /app
COPY . ./
ENTRYPOINT ConsoleApp1.exe

错误:

PS C:\Temp\UwpClassLibrary\ConsoleApp1\bin\Realease\netcoreapp2.0\win10-x86\publish> docker build -t consoleble .
Sending build context to Docker daemon 60.74MB
Step 1/4 : FROM microsoft/windowsservercore
---> db8182d67b6c
Step 2/4 : WORKDIR /app
---> Using cache
---> 72ad458b28d3
Step 3/4 : COPY . ./
---> d87225a29b50
Step 4/4 : ENTRYPOINT ConsoleApp1.exe
---> Running in a96daa3f030f
Removing intermediate container a96daa3f030f
---> a6f3d8500e20
Successfully built a6f3d8500e20
Successfully tagged consoleble:latest

.csproj文件

PS C:\Temp\UwpClassLibrary\ConsoleApp1\bin\Realease\netcoreapp2.0\win10-x86\publish> docker run consoleble

Unhandled Exception: System.TypeLoadException: Could not find Windows Runtime type 'Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementWatcher'.
at ConsoleApp1.Program.Main(String[] args)

0 个答案:

没有答案