You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编译Bloomberg API模拟器.NET项目示例脚本遇CS0246错误求助

问题描述

我有一个用于模拟Bloomberg API的.NET项目,其Examples文件夹中包含可运行的.cs示例脚本。我尝试通过命令提示符使用csc编译示例,执行命令:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\CSC.EXE IntradayBarDataRequest.cs

但编译后出现如下错误:

Microsoft (R) Visual C# Compiler version 4.8.4084.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

IntradayBarDataRequest.cs(17,11): error CS0246: The type or namespace name 'Bloomberglp' could not be found (are you
missing a using directive or an assembly reference?)
IntradayBarDataRequest.cs(106,45): error CS0246: The type or namespace name 'Event' could not be found (are you missing
a using directive or an assembly reference?)

请问我是否遗漏了某些操作?是否需要添加文件至文件夹,让编译器能够识别相关依赖?

解决方法
  • 你确实遗漏了依赖程序集引用的步骤。示例脚本依赖项目本身的Bloomberg模拟库(对应Bloomberglp命名空间),直接编译单个.cs文件时,编译器无法找到这些依赖的程序集文件。
  • 首先需要编译整个bemu项目,生成对应的.dll程序集文件(比如Bemu.dll,具体名称可查看项目编译输出)。
  • 然后在编译示例脚本的命令中,通过/reference(简写/r)参数添加对该程序集的引用。假设生成的Bemu.dll和示例脚本在同一目录下,编译命令应修改为:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\CSC.EXE /r:Bemu.dll IntradayBarDataRequest.cs
  • 关于Event的错误,大概率是因为该类型属于上述依赖库的一部分,添加正确的程序集引用后即可解决。

内容的提问来源于stack exchange,提问作者apg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 18:12:29