我在 Visual Studio 中为我的控制台应用程序创建了一个 DLL。在我的 DLL 中,我有一个名为 Dialog_MainMenu 的类,其中包含一个 *.cpp 文件和一个 *.h 文件。
以下错误消息:
错误 9 错误 LNK2001: 未解析的外部符号 "__declspec(dllimport) public: static enum Dialog_MainMenu::GAME_STATES Dialog_MainMenu::CurrentGameState" (_ imp ?CurrentGameState@Dialog_MainMenu@@2W4GAME_STATES@1@A) C:\Users\Kevin\Desktop\ c++ projects\development_testing\The Intense Adventure\Dialogs\Dialog_MainMenu.obj Dialogs
我有点不明白。这只发生在我向头文件中的原型添加枚举时。
头文件:
#ifdef DIALOG_MAINMENU_EXPORTS
#define DIALOG_MAINMENU_API __declspec(dllexport)
#else
#define DIALOG_MAINMENU_API __declspec(dllimport)
#endif
class Dialog_MainMenu {
public:
static DIALOG_MAINMENU_API enum GAME_STATES {
MAINMENU, GAME, OPTIONS, CREDITS, QUIT
};
static DIALOG_MAINMENU_API GAME_STATES CurrentGameState;
DIALOG_MAINMENU_API GAME_STATES GetState();
};
Run Code Online (Sandbox Code Playgroud)
(不知道问题是否出在这里,所以我会添加它) 一般的cpp文件:
//Get state
Dialog_MainMenu::GAME_STATES Dialog_MainMenu::GetState() {
// …Run Code Online (Sandbox Code Playgroud) 我正在关注Web服务器的示例应用程序,通过TCP使用端口处理传入请求.
代码示例应用程序:https://incredibits.io/project/windows-10-iot-internet-of-things-tips/windows-10-iot-raspberry-pi-web-server
在我的Windows 10机器上调试UWP应用程序时,尝试访问本地IP(192.168.xx < - Ofcourse我输入了我的实际本地IP),我得到了我应该得到的.应用程序得到一个传入的请求,并将一些数据返回给我(我的另一台计算机上的客户端).
我面临的问题是当我将其部署到运行Windows 10 IoT核心的Raspberry Pi 3(来自Insider的最新版本)时,我无法从客户端计算机访问该应用程序.这是Pi的防火墙或其他阻止这种情况的东西吗?
我可以通过端口8080访问IoT Core的Web界面,但是我无法访问在端口80上运行的应用程序.(我已经尝试将端口切换到另一个端口,在我的Windows 10本地工作但不在Pi上工作)
有没有人知道解决方案,或者遇到类似的问题?
注意: 我也尝试了一些例子(https://ms-iot.github.io/content/en-US/win10/samples/BlinkyWebServer.htm),这些例子再次适用于我的Windows 10 pc,并且可以访问通过我的其他PC如果他们在同一个网络上,但不在我的Pi上
我正在尝试构建 SHA256 ComputeHash 的等效版本(来自 C#,与下面示例的输出完全相同),以响应 Native/JavaScript。这是以下 C#:
public static string Hash(string input)
{
if (string.IsNullOrWhiteSpace(input)) return "";
using (SHA256 hasher = SHA256.Create())
{
// Convert the input string to a byte array and compute the hash.
byte[] data = hasher.ComputeHash(Encoding.Unicode.GetBytes(input));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i …Run Code Online (Sandbox Code Playgroud) 我的问题很简单,如何通过foreach访问我的gameobjects自定义C#脚本.
我试过以下:
foreach(TowerController go in GameObject.FindGameObjectsWithTag("Tower")) {
go.upgradeTowerProgress = false;
}
Run Code Online (Sandbox Code Playgroud)
似乎不起作用.不知道为什么,这就是我在这里问的原因!的xD
TowerController是我在带有标签塔的gameObjects上的自定义脚本.
我在 C# 中遇到了一个关于删除空格的相当奇怪的问题。
我当前的代码如下所示:
string s = "This is a string without spaces";
s = s.Replace(" ", string.Empty);
Run Code Online (Sandbox Code Playgroud)
在此示例中,“without”后面的最后一个空格是缩进(制表符),而不是实际的空格键空格。显然 String.Replace 并不关心这一点,因此它会忽略它,并在那里留下空白。
是否可以避免这个问题?
所以,我试图找出,如何确定我的变量是否正在增加它的价值,或者减少它.我知道我可以使用一个变量来存储旧值,但在这种情况下它不是一个选项.
int variable = 0;
variable = 1;
if(variable has increased) {
//Do Magic stuff
}
Run Code Online (Sandbox Code Playgroud)
基本上,我会怎么想这样做.我不知道是否有可能这样,没有旧值的容器,但我认为可能有一个C#函数,可以解决这个问题,可能是一个内存地址?
我还没有得到任何线索,这种方法或技术也被称之为,所以对此也很了解.
我有一个变量,它有很多我需要排序的内容.但是使用IndexOf和Substring,只是给我一个不那么明显的错误.
ArgumentOutOfRangeException:参数超出范围.
参数名称:startIndex
错误发生在"string lookThroughString = .."行上.
我的代码只是试图查看字符串,找到正确的内容,然后吐出来.
private string SCRIPT_CONTENT;
public string GetVariable(string variable_name) {
int length = 0;
string lookThroughString = SCRIPT_CONTENT.Substring(SCRIPT_CONTENT.IndexOf(variable_name));
foreach(char c in lookThroughString) {
if(c.ToString() != ";") {
length++;
}
}
return SCRIPT_CONTENT.Substring(SCRIPT_CONTENT.IndexOf(variable_name + "::"), length);
}
Run Code Online (Sandbox Code Playgroud)
我正在浏览的"脚本"/"内容"是:
spellName::Fireball;
spellID::1;
Run Code Online (Sandbox Code Playgroud)
我想要这个函数,从输入的变量名的开头(在本例中为'SpellName')基本返回,直到第一个分号.
我的目标是从C#代码中的Sitecore访问回收站,并将bin中的项目作为数据读取操作列表返回.
我目前的代码是基于我在Google上可以找到的文档以及我自己的经验,但它似乎并没有实际包含它声称的内容:
var recycleBinItems = Sitecore.Context.Database.Archives["recyclebin"].GetEntries(0, int.MaxValue);
var binItems = recycleBinItems as IList<ArchiveEntry> ?? recycleBinItems.ToList();
foreach (var item in binItems)
{
Response.Write(item.Name);
}
Run Code Online (Sandbox Code Playgroud)
上面应该只是从存档"recyclebin"获取ArchiveEntries列表,这是Sitecore(URL.COM/Sitecore)中的一个.
但结果如下:

这不是预期的结果,因为我要求回收站的条目而不是它们的属性/设置(或者它返回的任何东西)
我问过我的工作场所,似乎没有人知道在哪里访问它,我希望有人可以帮助我在这里:)
我刚刚从https://code.visualstudio.com/下载了 Visual Studio Code App ,当我尝试安装它时,它只是自行安装,没有更改安装路径的选项。
我有一个外部硬盘驱动器,我希望在其中放置 IDE,而不是本地硬盘驱动器。我怎样才能改变这个?
现在,我正在使用Azure Functions来实现HTTP无服务器功能,并且在访问存储帐户上的单个Blob存储项时,我需要使传入的请求同步。
我想发生的事情如下:
// Incoming Request 1
// .. Get blob
await myBlob.AcquireLeaseAsync(TimeSpan.FromMinutes(1), leaseId);
// .. 10 seconds later
await myblob.ReleaseLeaseAsync(AccessCondition.GenerateEmptyCondition());
//
// MEANWHILE
//
// Incoming Request 2 (Happens 1-2 seconds after Request 1)
// .. Get blob
// .. -- Wait until Lease is released from Request 1 --
await myBlob.AcquireLeaseAsync(TimeSpan.FromMinutes(1), leaseId);
// Repeat...
Run Code Online (Sandbox Code Playgroud)
但是我注意到,当我尝试在请求2上获取Blob时,它不会同步等待直到从请求1释放Blob租约,它只是返回一个错误,该错误表明该Blob上已经有活动的Lease,然后继续。
在Azure功能中是否可以具有上述同步系统?
当我尝试运行它时,它给我以下错误消息:
将varchar值'category_id'转换为数据类型int时转换失败.
这是我的SQL和参数代码,我认为它应该可以工作,但事实并非如此.
mycmd.CommandText="SELECT * FROM categories WHERE @db_property = @property_id";
// This contains a string "category_id", which is correct.
mycmd.Parameters.Add("@db_property", SqlDbType.VarChar).Value=db_property_field;
// This contains an Int, referring to the category_id in database. As of now, this is 1
mycmd.Parameters.Add("@property_id", SqlDbType.Int).Value=property_id;
Run Code Online (Sandbox Code Playgroud)
在我完成这段代码之后,我通过Reader运行它,这就是我收到上面的错误消息的地方.一直问老师,我班上优秀的学生,没有人能找到问题所在的线索.
假设我有一个像这样的字符串:
This is a string-----------------------------
Run Code Online (Sandbox Code Playgroud)
- - 是必须删除的空格.只有最后一个单词后面的空格,而不是单词之间的空格.
所以基本上,我怎样才能将上述内容修改为:
This is a string
Run Code Online (Sandbox Code Playgroud)
句子末尾没有空格.
编辑:注意:这必须是动态的,因为我无法预测字符串中的内容.但它最终总会有很多空白.