ubuntu 14.04 上的 dnx web 抛出 "System.Runtime.InteropServices.Marshal" 异常 (1.0.0-beta8)
dnx web on ubuntu 14.04 throws "System.Runtime.InteropServices.Marshal" exception (1.0.0-beta8)
我正在关注各种博客文章,展示如何获取 ASP.NET 核心 1.0 应用程序(以前称为 ASP.NET 5),然后 运行 次安装正确的 .net 核心 Linux,所以你可以 运行 on Linux,特别是 ubuntu 14.04 lts。
我安装了 .net 核心工具(dnvm 和 dnx),我有一个 ASP.NET 应用程序,它只是标准模板应用程序,我已经创建了一个包含它的存储库,并且正在尝试运行 它在我的 Ubuntu 系统上。 Windows 上的最新 .Net 和 Visual Studio 工具是 1.0.0-beta8,我的 ubuntu 盒子上也有它,它报告说 Mono-x64-1.0.0-beta8 -15858 已安装。
我将我的源代码克隆到 ubuntu 系统并 运行 dnu 恢复,这成功了。
从包含 project.json 的文件夹中,我 运行 dnx web
得到了这个:
Application startup exception: System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.Marshal' from assembly 'System.Reflection.Metadata'.
at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock (System.IO.Stream stream, Boolean isFileStream, Int64 start, Int32 size) [0x00000] in <filename unknown>:0
at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, PEStreamOptions options, Nullable`1 sizeOpt) [0x00000] in <filename unknown>:0
at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, PEStreamOptions options) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream (System.IO.Stream peStream, PEStreamOptions options) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.CSharp.MetadataReferenceExtensions.CreateAssemblyMetadata (IMetadataFileReference fileReference) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.CSharp.RoslynCompiler+<>c__DisplayClass8_0.<.ctor>b__1 (Microsoft.Dnx.Compilation.Caching.CacheContext ctx) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.CacheExtensions+<>c__DisplayClass0_0`1[Microsoft.CodeAnalysis.AssemblyMetadata].<Get>b__0 (Microsoft.Dnx.Compilation.Caching.CacheContext ctx) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.Cache.CreateEntry (System.Object k, System.Func`2 acquire) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.Cache+<>c__DisplayClass5_0.<AddEntry>b__0 () [0x00000] in <filename unknown>:0
at System.Lazy`1[Microsoft.Dnx.Compilation.Caching.Cache+CacheEntry].InitValue () [0x00000] in <filename unknown>:0
这是否表明存在组件版本冲突或我的 .dnx 文件夹中缺少某些内容,或者我的项目源代码中存在错误?
起初我看到了另一个奇怪的异常,我认为这与 dnvm 的“1.0.0-rc2”构建有关,今天在 public 服务器上短暂可见,然后消失了。
一些常规设置步骤:
- 查看~/.config/NuGet/NuGet.Config,应该是这样的:
。
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetbeta8/api/v2/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
</configuration>
确保 dnx、dnu 和 dnvm 二进制文件存在并且是最新的。确保 libuv 存在并且是正确的版本。如果它们不存在,则安装 运行 次。 (使用 dnvm list 检查它们,使用 dnvm install 安装。)
克隆您的来源。
Select 通过 dnvm 使用的 dnx 版本。
确保您的 user-account-level dnx 运行time 包已通过 dnu restore 恢复。
??什么??
转到包含 project.json 和 运行 dnx web
的文件夹。成功了吗?
更新:如果我在 ubuntu 14.04 上使用 dnvm 使用 1.0.0-beta8,dnx web 运行time 错误可能是 Missing method AllocHGlobal in assembly /home/user/.dnx/runtimes/dnx-mono.1.0.0-beta8/bin/System.Reflection.Metadata.dll, type System.Runtime.InteropServices.Marshal
或者可能是 System.Runtime.InteropServices.Marshall 在标题中。
更新 2:当我在 NuGet.Config 中有错误的内容时,我看到了一些开发者频道(内部未发布)的构建。
dnvm 列表的当前输出:
me@mabox:~$ dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta7 mono linux/osx
* 1.0.0-beta8 mono linux/osx default
更新 3:一旦我安装了 coreclr target 运行time type,这个问题就消失了。安装后,dnvm 列表如下所示:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
* 1.0.0-beta8 coreclr x64 linux
1.0.0-beta8 mono linux/osx default
更新 4:以下两个答案都包含基本信息。我犯的一个错误是假设 Ubuntu 14.04 的 apt-get 存储库中包含的古老的 mono-2.x 版本对于 DNX 使用是可接受的。他们不是,而是在我写这篇文章的时候,只有最近的 mono-2015.11.xx 才知道每晚构建是有效的。在未来的某个时候,一旦发布了稳定的 4.3.0+ 版本,您可能会使用它和 DNX,但我不能肯定地说。
The latest .Net and Visual Studio tooling on Windows is 1.0.0-beta8,
and I have that also on my ubuntu box, which reports that
Mono-x64-1.0.0-beta8-15858 is intalled.
对我来说,您似乎 运行 反对相同的 运行 时间。
您是否尝试过 运行宁 dnvm upgrade
而不是针对夜间构建服务器?在我看来,您的代码可能在 beta8-15858
运行 时间使用 beta8
程序集。
运行 dnu feeds list
在您的 Ubuntu 框中,以确保您针对的是稳定频道而不是开发人员频道(应该只看到默认提要)。
如果您定位到错误的供稿,您可以从 ~/.config/NuGet/Nuget.Config
下用户文件夹中的 nuget.config
文件更改它。
执行以下操作以确保您处于正确的运行时间:
- 删除
~/.dnx/runtimes
中所有现有的 运行 次
dnvm upgrade
dnvm install -r coreclr latest
- 然后 运行
dnu restore
在你的项目上
dnx web
现在应该可以工作了
可以在 ubuntu 14.04 上针对单声道 运行 beta8。我刚刚尝试了一下并成功了,这是我遵循的步骤;
按照说明安装了 dnvm 和 libuv here。
运行 dnvm install 1.0.0-beta8
已安装 mono-snapshot-latest 并已执行 . mono-snapshot mono
克隆了这个新的 MVC 6 beta8 项目git clone https://github.com/staff0rd/TinyMvc -b beta8
运行 mozroots --import --sync
所以 nuget doesn't throw TrustFailure 异常
执行了cd TinyMvc
和dnu restore
运行 dnx web
;
结果:
[mono-2015.11.13+00.47.00]root@8792d900344b:/TinyMvc# dnx web
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
针对来自 here.
的空 Ubuntu 14.04 执行
我正在关注各种博客文章,展示如何获取 ASP.NET 核心 1.0 应用程序(以前称为 ASP.NET 5),然后 运行 次安装正确的 .net 核心 Linux,所以你可以 运行 on Linux,特别是 ubuntu 14.04 lts。
我安装了 .net 核心工具(dnvm 和 dnx),我有一个 ASP.NET 应用程序,它只是标准模板应用程序,我已经创建了一个包含它的存储库,并且正在尝试运行 它在我的 Ubuntu 系统上。 Windows 上的最新 .Net 和 Visual Studio 工具是 1.0.0-beta8,我的 ubuntu 盒子上也有它,它报告说 Mono-x64-1.0.0-beta8 -15858 已安装。
我将我的源代码克隆到 ubuntu 系统并 运行 dnu 恢复,这成功了。
从包含 project.json 的文件夹中,我 运行 dnx web
得到了这个:
Application startup exception: System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.Marshal' from assembly 'System.Reflection.Metadata'.
at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock (System.IO.Stream stream, Boolean isFileStream, Int64 start, Int32 size) [0x00000] in <filename unknown>:0
at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, PEStreamOptions options, Nullable`1 sizeOpt) [0x00000] in <filename unknown>:0
at System.Reflection.PortableExecutable.PEReader..ctor (System.IO.Stream peStream, PEStreamOptions options) [0x00000] in <filename unknown>:0
at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream (System.IO.Stream peStream, PEStreamOptions options) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.CSharp.MetadataReferenceExtensions.CreateAssemblyMetadata (IMetadataFileReference fileReference) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.CSharp.RoslynCompiler+<>c__DisplayClass8_0.<.ctor>b__1 (Microsoft.Dnx.Compilation.Caching.CacheContext ctx) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.CacheExtensions+<>c__DisplayClass0_0`1[Microsoft.CodeAnalysis.AssemblyMetadata].<Get>b__0 (Microsoft.Dnx.Compilation.Caching.CacheContext ctx) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.Cache.CreateEntry (System.Object k, System.Func`2 acquire) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Compilation.Caching.Cache+<>c__DisplayClass5_0.<AddEntry>b__0 () [0x00000] in <filename unknown>:0
at System.Lazy`1[Microsoft.Dnx.Compilation.Caching.Cache+CacheEntry].InitValue () [0x00000] in <filename unknown>:0
这是否表明存在组件版本冲突或我的 .dnx 文件夹中缺少某些内容,或者我的项目源代码中存在错误?
起初我看到了另一个奇怪的异常,我认为这与 dnvm 的“1.0.0-rc2”构建有关,今天在 public 服务器上短暂可见,然后消失了。
一些常规设置步骤:
- 查看~/.config/NuGet/NuGet.Config,应该是这样的:
。
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetbeta8/api/v2/" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<disabledPackageSources />
</configuration>
确保 dnx、dnu 和 dnvm 二进制文件存在并且是最新的。确保 libuv 存在并且是正确的版本。如果它们不存在,则安装 运行 次。 (使用 dnvm list 检查它们,使用 dnvm install 安装。)
克隆您的来源。
Select 通过 dnvm 使用的 dnx 版本。
确保您的 user-account-level dnx 运行time 包已通过 dnu restore 恢复。
??什么??
转到包含 project.json 和 运行
dnx web
的文件夹。成功了吗?
更新:如果我在 ubuntu 14.04 上使用 dnvm 使用 1.0.0-beta8,dnx web 运行time 错误可能是 Missing method AllocHGlobal in assembly /home/user/.dnx/runtimes/dnx-mono.1.0.0-beta8/bin/System.Reflection.Metadata.dll, type System.Runtime.InteropServices.Marshal
或者可能是 System.Runtime.InteropServices.Marshall 在标题中。
更新 2:当我在 NuGet.Config 中有错误的内容时,我看到了一些开发者频道(内部未发布)的构建。
dnvm 列表的当前输出:
me@mabox:~$ dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta7 mono linux/osx
* 1.0.0-beta8 mono linux/osx default
更新 3:一旦我安装了 coreclr target 运行time type,这个问题就消失了。安装后,dnvm 列表如下所示:
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
* 1.0.0-beta8 coreclr x64 linux
1.0.0-beta8 mono linux/osx default
更新 4:以下两个答案都包含基本信息。我犯的一个错误是假设 Ubuntu 14.04 的 apt-get 存储库中包含的古老的 mono-2.x 版本对于 DNX 使用是可接受的。他们不是,而是在我写这篇文章的时候,只有最近的 mono-2015.11.xx 才知道每晚构建是有效的。在未来的某个时候,一旦发布了稳定的 4.3.0+ 版本,您可能会使用它和 DNX,但我不能肯定地说。
The latest .Net and Visual Studio tooling on Windows is 1.0.0-beta8, and I have that also on my ubuntu box, which reports that Mono-x64-1.0.0-beta8-15858 is intalled.
对我来说,您似乎 运行 反对相同的 运行 时间。
您是否尝试过 运行宁 dnvm upgrade
而不是针对夜间构建服务器?在我看来,您的代码可能在 beta8-15858
运行 时间使用 beta8
程序集。
运行 dnu feeds list
在您的 Ubuntu 框中,以确保您针对的是稳定频道而不是开发人员频道(应该只看到默认提要)。
如果您定位到错误的供稿,您可以从 ~/.config/NuGet/Nuget.Config
下用户文件夹中的 nuget.config
文件更改它。
执行以下操作以确保您处于正确的运行时间:
- 删除
~/.dnx/runtimes
中所有现有的 运行 次
dnvm upgrade
dnvm install -r coreclr latest
- 然后 运行
dnu restore
在你的项目上 dnx web
现在应该可以工作了
可以在 ubuntu 14.04 上针对单声道 运行 beta8。我刚刚尝试了一下并成功了,这是我遵循的步骤;
按照说明安装了 dnvm 和 libuv here。
运行
dnvm install 1.0.0-beta8
已安装 mono-snapshot-latest 并已执行
. mono-snapshot mono
克隆了这个新的 MVC 6 beta8 项目
git clone https://github.com/staff0rd/TinyMvc -b beta8
运行
mozroots --import --sync
所以 nuget doesn't throw TrustFailure 异常执行了
cd TinyMvc
和dnu restore
运行
dnx web
;
结果:
[mono-2015.11.13+00.47.00]root@8792d900344b:/TinyMvc# dnx web
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
针对来自 here.
的空 Ubuntu 14.04 执行