【发布时间】:2015-04-28 03:54:23
【问题描述】:
简介
我正在开发一种可以解释和使用 API 蓝图的工具。
我创建了一个新的控制台应用程序,添加了SnowCrash.NET nuget package 并编写了以下代码:
static void Main(string[] args)
{
snowcrashCLR.Blueprint blueprint;
snowcrashCLR.Result result;
var path = args.Length > 1 ? args[1] : @"c:\";
snowcrashCLR.SnowCrashCLR.parse(path, out blueprint, out result);
if (result != null)
{
var warnings = result.GetWarningsCs();
foreach (var warning in warnings)
{
Console.WriteLine("{0}: {1}", warning.code, warning.message);
}
}
}
问题
当我将代码(复制 bin 文件夹)部署到与我的开发环境不同的计算机时,我得到一个指向 SnowCrash.dll 的 FileNotFoundException
这是错误消息中的快照:
无法加载文件或程序集“snowcrashCLR.DLL”或其依赖项之一。找不到指定的模块。
详情:
[FileNotFoundException: Could not load file or assembly 'snowcrashCLR.DLL' or one of its dependencies. The specified module could not be found.]
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.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
System.Reflection.Assembly.Load(String assemblyString) +28
到目前为止我已经尝试过什么
- 我在两台机器上都使用了 sysinternal procmon 进行比较,看起来我的开发机器(运行良好)正在加载这个 DLL:
加载图片 C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualC.STLCLR\v4.0_2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualC.STLCLR.dll
- 我的计算机上安装了这些运行时,该应用程序运行良好
MS Visual C++ 2005 Redist (x64)
MS Visual C++ 2008 Redist (x64) 9.0.30729.4148
MS Visual C++ 2008 Redist (x64) 9.0.30729.6161
MS Visual C++ 2008 Redist (x86) 9.0.30729.4148
MS Visual C++ 2008 Redist (x86) 9.0.30729.6161
MS Visual C++ 2010 x64 Redist - 10.0.40219
MS Visual C++ 2013 x64 Redist - 12.0.30501
MS Visual C++ 2013 x86 Redist - 12.0.30501
在出现错误(不工作)的计算机上,我安装了与上述相同的运行时列表,但这并没有解决问题或使其正常工作。
我在那台计算机上安装了 Visual Studio,以前无法正常工作,当我尝试我的应用程序时,它工作了
如果您有更好的知识或有类似问题的战斗伤疤,我们非常感谢您的帮助。
【问题讨论】:
-
您是否尝试将应用程序池上的 32bit 参数设置为 true?
-
我确实尝试过(启用 32 位),但在 IIS 8.0 下没有帮助,但这使它在 IIS 7.x 下工作。
-
您必须在 IIS 8.0 下托管吗?使用 OWIN 的自托管 API 怎么样?您可以使用 TopShelf 和此包创建服务:github.com/dennisroche/Topshelf.Owin
-
计划是允许它作为 ASP.net 模块运行并成为同一网站的一部分,因此这里选择 IIS。我不是想创建一个独立的工具。
-
您是在部署 Debug 版本还是 Release 版本?它们使用不同的运行时,并且调试运行时不能作为可再发行组件使用。
标签: c# visual-c++ stl c++-cli