簡體   English   中英

在Mono Docker容器中運行控制台應用程序

[英]Run a console application in a Mono Docker container

我有一個控制台應用程序,可以在Windows上正常工作。 /bin/release文件夾中,我有一些構建工件(.dll,.exe等)以及類似這樣的Dockerfile:

FROM mono:4.0

COPY . /app

WORKDIR /app

ENTRYPOINT ["mono", "./EntryPoint.exe"]

我生成圖像,運行容器,但是當按下EntryPoint.exe時,我得到類似以下內容:

Rebus.Workers.ThreadBased.ThreadWorker DEBUG (Rebus 1 worker 1): Starting (thread-based) worker Rebus 1 worker 1
Default Error: 0 : An exception occurred creating the host System.NullReferenceException: Object reference not set to an
 instance of an object
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.get_ParentDefinitionMethodInfo () [0x00000] in <filename un
known>:0
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.MethodInfo method, B
indingFlags flags) [0x00000] in <filename unknown>:0
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.GetParentDefinition (System.Reflection.PropertyInfo propert
y) [0x00000] in <filename unknown>:0
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.IsDefined (System.Reflection.PropertyInfo element, System.T
ype attributeType, Boolean inherit) [0x00000] in <filename unknown>:0
  at Ninject.Infrastructure.Language.ExtensionsForMemberInfo.HasAttribute (System.Reflection.MemberInfo member, System.T
ype type) [0x00000] in <filename unknown>:0
  at Ninject.Selection.Heuristics.StandardInjectionHeuristic.ShouldInject (System.Reflection.MemberInfo member) [0x00000
] in <filename unknown>:0
  at Ninject.Selection.Selector+<>c__DisplayClass3.<SelectPropertiesForInjection>b__2 (IInjectionHeuristic h) [0x00000]
in <filename unknown>:0

我將可移植性分析器擴展安裝到Visual Studio,它在Mono 3.3上看起來有些問題。 常見的問題是:

  • add_SerializeObjectState(...)
  • System.Security.SecurityTransparentAttribute #ctor
  • System.Configuration.ElementInformation.get_IsPresent()
  • System.Reflection.MemberInfo.get_MemberType()
  • System.Net.Sockets.TcpClient.BeginConnect()

受影響最大的庫是:

  • Common.Loggin 3.3.1
  • 實體框架6
  • MongoDB 1.9.2
  • Newtonsoft.Json 7
  • 頂架3.3.1

就像我已經說過的那樣,.NET可移植性分析器針對Mono 3.3檢查可移植性(目前4.2已發布)。 如何檢查較新的版本(Mono 4將不勝感激)? 我希望Mono 4上的一些錯誤會消失。

我能做什么? 如果第三方庫(例如MongoDB)遇到可移植性問題,該怎么辦?

這可能是一堆事情。 docker hub上用於mono:4.0的docker文件來自wheezy,並且執行mono-devel而不是mono-complete安裝。 如果尚未考慮這些因素(例如,您是在運行debian衍生產品還是在SE衍生產品上運行,並且需要單安裝完整安裝),那將是一個好主意。 另外,如果您在Windows上編譯並且僅在linux上復制和運行,則可能會遇到兼容性問題,因此使用目標單聲道進行構建也將對此有所幫助。 另外,您在哪里以及如何烘烤docker映像?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM